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
|
|
|
#include "image.h"
|
|
|
|
|
|
|
|
namespace Image
|
|
|
|
{
|
|
|
|
void threshold(SDL_Surface *image, int lowerBound, int upperBound)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
for (int i = 0; i < image->w * image->h; ++i)
|
|
|
|
{
|
|
|
|
int gray = GRAY(((uint32_t*)image->pixels)[i]);
|
|
|
|
if (gray > lowerBound && gray < upperBound)
|
|
|
|
((uint32_t*)image->pixels)[i] = 0xffffffff;
|
|
|
|
else
|
|
|
|
((uint32_t*)image->pixels)[i] = 0xff000000;
|
|
|
|
//gray | (gray << 8) | (gray << 16);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2007-03-01 14:00:51 +01:00
|
|
|
|
|
|
|
SDL_Surface *copySurface(SDL_Surface *s)
|
|
|
|
{
|
|
|
|
SDL_Surface *copy = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h,
|
|
|
|
s->format->BitsPerPixel,
|
|
|
|
s->format->Rmask, s->format->Gmask,
|
|
|
|
s->format->Bmask, s->format->Amask);
|
|
|
|
SDL_BlitSurface(s, NULL, copy, NULL);
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-26 11:45:05 +01:00
|
|
|
}
|