#ifndef _IMAGE_H_ #define _IMAGE_H_ #include // get pixel/something in array p of size w*h #define PX_(p, x, y, w, h) ((p)[(x)+(y)*(w)]) // get pixel in SDL_Surface i #define PX(i,x,y) (PX_((uint32_t*)(i)->pixels, (x), (y), (i)->w, (i)->h)) // get color components of pixel value. should probably be done in a nicer way #define PXR(px) ((px) & 0xff) #define PXG(px) (((px) & 0xff00) >> 8) #define PXB(px) (((px) & 0xff0000) >> 16) //get the grayscale value of the pixel #define GRAY(px) ((PXR(px) + PXG(px) + PXB(px)) / 3) // iterate over SDL_Surface s with variables x, y #define iter_pixels(s,x,y) for (x = 0; x < s->w; x++) for (y = 0; y < s->h; y++) namespace Image { void threshold(SDL_Surface *image, int lowerBound, int upperBound); SDL_Surface *copySurface(SDL_Surface *s); } #endif /* ifndef _IMAGE_H_ */