haraldhv
/
aigo
Archived
1
0
Fork 0
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.
aigo/lib/image.h

32 lines
995 B
C
Raw Permalink Normal View History

#ifndef _IMAGE_H_
#define _IMAGE_H_
#include <SDL/SDL.h>
#include "mask.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);
void erosion(SDL_Surface *dest, SDL_Surface *src, Mask::mask *mask);
void dilation(SDL_Surface *dest, SDL_Surface *src, Mask::mask *mask);
2007-03-01 14:00:51 +01:00
SDL_Surface *copySurface(SDL_Surface *s);
}
#endif /* ifndef _IMAGE_H_ */