File image.h of Package arachne
/*
image.h
Handy definitions of an image type.
*/
/*
Copyright (C) 2007 Hayden Walles
This file is part of Arachne.
Arachne is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Arachne is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
typedef struct {
unsigned char *pixels;
int width,height;
} IMAGE;
#define IMAGE_E_OK 0
#define IMAGE_E_MEMORY 1
#define IMAGE_E_FILE 2
#define IMAGE_E_IO 3
#define IMAGE_E_DECODE 4
#define imageHeight(i) (i->height)
#define imageRows(i) (i->height)
#define imageWidth(i) (i->width)
#define imageCols(i) (i->width)
#define getRed(i,r,c) (i->pixels[((r)*i->width+(c))*4])
#define getGreen(i,r,c) (i->pixels[((r)*i->width+(c))*4+1])
#define getBlue(i,r,c) (i->pixels[((r)*i->width+(c))*4+2])
void setPixel(IMAGE *image,int row, int col, int r, int g, int b);
IMAGE *loadImage(char *filename, int *error);
IMAGE *newImage(int width,int height,int *error);
int saveImage(char *name, IMAGE *image,int *error);
void deleteImage(IMAGE *image);
char *lastImageErrorString(void);