| 89 | } |
| 90 | |
| 91 | Vec2 NinePatchImageParser::parseHorizontalMargin() const |
| 92 | { |
| 93 | unsigned char* data = _image->getData(); |
| 94 | |
| 95 | data = data + this->getPixelOriginOffset(Direction::HORIZONTAL); |
| 96 | unsigned char lastPixel = *(data + 3); |
| 97 | int x1 = 0; |
| 98 | int x2 = 0; |
| 99 | |
| 100 | int length = _imageFrame.origin.x + this->getFrameWidth(); |
| 101 | for (int i = (int)_imageFrame.origin.x; i <= length; i++) |
| 102 | { |
| 103 | unsigned char pixel = *(data + (i - (int)_imageFrame.origin.x) * 4 + 3); |
| 104 | if (pixel != lastPixel) |
| 105 | { |
| 106 | if (pixel > 0) |
| 107 | { |
| 108 | x1 = (i - (int)_imageFrame.origin.x); |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | x2 = (i - (int)_imageFrame.origin.x); |
| 113 | break; |
| 114 | } |
| 115 | } |
| 116 | lastPixel = pixel; |
| 117 | } |
| 118 | return Vec2(x1, x2); |
| 119 | } |
| 120 | |
| 121 | Vec2 NinePatchImageParser::parseVerticalMargin() const |
| 122 | { |
no test coverage detected