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

Method parseHorizontalMargin

core/base/NinePatchImageParser.cpp:91–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91Vec2 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
121Vec2 NinePatchImageParser::parseVerticalMargin() const
122{

Callers 1

parseCapInsetMethod · 0.95

Calls 4

getPixelOriginOffsetMethod · 0.95
getFrameWidthMethod · 0.95
Vec2Class · 0.70
getDataMethod · 0.45

Tested by

no test coverage detected