/*
 *  Raster graphics library
 * 
 *  Copyright (c) 1997 Alfredo K. Kojima
 * 
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *  
 *  This library 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
 *  Library General Public License for more details.
 *  
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


#ifndef RLRASTER_H_
#define RLRASTER_H_

#include <X11/Xlib.h>
#include <X11/Xutil.h>

/*
 * describes a screen in terms of depth, visual, number of colors
 * we can use, if we should do dithering, and what colors to use for
 * dithering.
 */
typedef struct RContext {
    Display *dpy;
    Colormap cmap;
    int mode;

    GC copy_gc;

    Visual *visual;
    int depth;
    Window drawable;		       /* window to pass for XCreatePixmap().*/
				       /* generally = root */
    int class;
    
    /* only used for pseudocolor and grayscale */
    int cpc;			       /* colors per channel */
    int ncolors;		       /* total number of colors we can use */
    XColor *colors;		       /* internal colormap */
} RContext;

/* image display modes */
#define RM_DITHER	0
#define RM_MATCH	1



typedef struct RColor {
    unsigned char red, green, blue;
} RColor;


/*
 * internal 24bit+alpha image representation
 */
typedef struct RImage {
    int width, height;		       /* size of the image */
    RColor background;		       /* background color */
    unsigned char *data[4];	       /* image data (R,G,B,A) */
} RImage;



#define WBEV_SUNKEN	-1
/* 1 pixel wide */
#define WBEV_RAISED	1
/* 1 pixel wide on top/left 2 on bottom/right */
#define WBEV_RAISED2	2


#define WGRD_HORIZONTAL	2
#define WGRD_VERTICAL	3
#define WGRD_DIAGONAL	4

/* cpc == colors per channel for the dithering colormap */
RContext *RCreateContext(Display *dpy, XVisualInfo *vinfo, int screen_number,
			 int mode, int cpc);

RImage *RCreateImage(int width, int height, int alpha);

RImage *RCloneImage(RImage *image);

RImage *RGetSubImage(RImage *image, int x, int y, int width, int height);

RImage *RLoadImage(RContext *context, char *file);

int RDestroyImage(RImage *image);

int RBevelImage(RImage *image, int bevel_type);

int RCombineImages(RImage *image, RImage *src);

int RCombineArea(RImage *image, RImage *src, int sx, int sy, int width,
		 int height, int dx, int dy);

RImage *RScaleImage(RImage *image, int new_width, int new_height);


RImage *RRenderGradient(int width, int height, RColor *from, RColor *to,
			int style);

int RConvertImage(RContext *context, RImage *image, Pixmap *pixmap);

int RConvertImageMask(RContext *context, RImage *image, Pixmap *pixmap,
		      Pixmap *mask, int threshold);


extern char RErrorString[];
#endif
