#ifndef _PIXMAP_H_INCLUDED
#define _PIXMAP_H_INCLUDED
/* A facade class to demonstartae image processing using imagemagick API */
/* www.hackorama.com kishan@hackorama.com 2005/2006 */
#include <iostream>
#include <magick/api.h> /* MagickCore C API */
#define MAX_RGB 65535
using namespace std;
class Pixmap
{
public:
Pixmap();
Pixmap(Image *image);
~Pixmap();
Image* getImage();
void init();
int loadImage(char* filename);
void writeImage(char *filename);
void writeImage(char *filename, int i);
int getWidth();
int getHeight();
bool isValid();
int maxRGB();
bool greenPixel(int x, int y);
bool redPixel(int x, int y);
bool bluePixel(int x, int y);
bool whitePixel(int x, int y); // == 3 * max_rgb
bool blackPixel(int x, int y); // == 0
bool colorPixel(int x, int y); // !white || !black
bool darkPixel(int x, int y); // >= max_rgb
bool lightPixel(int x, int y); // < max_rgb
int getPixel(int x, int y);
bool setPixel(int x, int y, int r, int g, int b);
bool setPixel(int x, int y);
bool markPixels(int x, int y, int r, int g, int b, int border);
void markHLine(int x1, int x2, int y);
void markHLine(int y);
void markVLine(int y1, int y2, int x);
void markVLine(int x);
bool switchPixel(int x, int y, int r, int g, int b,
int new_r, int new_g, int new_b);
void switchColor(int r, int g, int b,
int new_r, int new_g, int new_b);
void setPen(int r, int g, int b);
void clear();
void clear(int r, int g, int b);
void setDebug(bool flag);
private:
bool inRange(int x, int y);
int convertRGB(int x);
Image *image, *image_out;
ImageInfo *image_info;
PixelPacket pixel;
PixelPacket *p;
int width, height;
int max_rgb;
bool debug;
bool ok;
int pen_r, pen_g, pen_b;
};
#endif /* _PIXMAP_H_INCLUDED */
syntax highlighted by Code2HTML, v. 0.9