Image manipulation.
Some lines about image manipulation, here for objective-c, but can be used in any c-alike language.
The codes manipulate images on a pixel level.
Now, assume you have an inMaskImage and you want it to be flipped by the y-axis into the globMaskImage:
for ( row = 0; row < h; row++ ) {
size_t p = row * w;
for ( col = 0; col < w; col++, p+=1 ) {
size_t m = row * w + (w-col);
globMaskImage[m] = inMaskImage[p];;
}
}
Only copying a a selection of an image that is defined by an NSRect:
int minX = (int)NSMinX(bounds);
int maxX = (int)NSMaxX(bounds);
int minY = (int)NSMinY(bounds);
int maxY = (int)NSMaxY(bounds);
for ( row = minY; row < maxY; row++ ) {
size_t p = row * w + minX;
for ( col = minX; col < maxX; col++, p+=1 ) {
globMaskImage[p] = inMaskImage[p];
}
}