MCPcopy Create free account
hub / github.com/axmolengine/axmol / parseVerticalMargin

Method parseVerticalMargin

core/base/NinePatchImageParser.cpp:121–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121Vec2 NinePatchImageParser::parseVerticalMargin() const
122{
123 unsigned char* data = _image->getData();
124 int imageWidth = _image->getWidth();
125
126 int y1 = 0;
127 int y2 = 0;
128
129 data = data + this->getPixelOriginOffset(Direction::VERTICAL);
130 unsigned char lastPixel = *(data + 3);
131
132 int length = (int)(_imageFrame.origin.y + this->getFrameHeight());
133 for (int i = _imageFrame.origin.y; i <= length; i++)
134 {
135 unsigned char pixel = *(data + (i - (int)_imageFrame.origin.y) * imageWidth * 4 + 3);
136 if (pixel != lastPixel)
137 {
138 if (pixel > 0)
139 {
140 y1 = (i - (int)_imageFrame.origin.y);
141 }
142 else
143 {
144 y2 = (i - (int)_imageFrame.origin.y);
145 break;
146 }
147 }
148 lastPixel = pixel;
149 }
150 return Vec2(y1, y2);
151}
152
153Rect NinePatchImageParser::parseCapInset() const
154{

Callers 1

parseCapInsetMethod · 0.95

Calls 5

getPixelOriginOffsetMethod · 0.95
getFrameHeightMethod · 0.95
Vec2Class · 0.70
getDataMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected