MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / calculateBounds

Method calculateBounds

framework/image.cpp:128–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126void *PaletteImageLock::getData() { return this->img->indices.get(); }
127
128void PaletteImage::calculateBounds()
129{
130 unsigned int minX = this->size.x, minY = this->size.y, maxX = 0, maxY = 0;
131
132 for (unsigned int y = 0; y < this->size.y; y++)
133 {
134 for (unsigned int x = 0; x < this->size.x; x++)
135 {
136 unsigned int offset = y * this->size.x + x;
137 if (this->indices[offset])
138 {
139 if (minX > x)
140 minX = x;
141 if (minY > y)
142 minY = y;
143 if (maxX < x)
144 maxX = x;
145 if (maxY < y)
146 maxY = y;
147 }
148 }
149 }
150 this->bounds = {minX, minY, maxX, maxY};
151}
152
153LazyImage::LazyImage() : Image({0, 0}) {}
154

Callers 3

loadMethod · 0.80
loadStratMethod · 0.80
loadShadowMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected