This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
2007-02-26 11:45:05 +01:00
|
|
|
#ifndef _IMAGE_H_
|
|
|
|
#define _IMAGE_H_
|
|
|
|
|
|
|
|
#include <SDL/SDL.h>
|
|
|
|
|
|
|
|
// 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);
|
2007-03-01 14:00:51 +01:00
|
|
|
SDL_Surface *copySurface(SDL_Surface *s);
|
2007-02-26 11:45:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ifndef _IMAGE_H_ */
|