Hi, the last part.
I need help with two functions:
GrImage *GrImageBuild(char *pixels,int w,int h,GrColorTableP colors); GrImage *GrImageBuildUsedAsPattern(char *pixels,int w,int h, GrColorTableP colors);
they do the same, but GrImageBuildUsedAsPattern calls GrBuildPixmap and GrImageBuild is a real function. I don't know why.
I have put the whole new user's manual zipped here: http://www.terra.es/personal/malfer/grx/resourc.htm I'm waiting for comments.
Gretings, M.Alvarez
* Image manipulation (next to patterned line drawing)
GRX defines the GrImage type like a GrPixmap synonym:
#define GrImage GrPixmap
nevertheless the GrImage type enforces the image character of this object, so for compatibility with future GRX versions use the next functions if you need to convert between 'GrImage' and 'GrPixmap' objects:
GrImage *GrImageFromPattern(GrPattern *p); GrPattern *GrPatternFromImage(GrImage *p);
the 'GrImageFromPattern' function returns NULL if the 'GrPattern' given is not a 'GrPixmap'.
Like pixmaps patterns images are dependent of the actual video mode set. So the library provides functions to create images in a mode-independent way:
GrImage *GrImageBuild(char *pixels,int w,int h,GrColorTableP colors); GrImage *GrImageFromContext(GrContext *c);
these functions work like the 'GrBuildPixmap' and 'GrConvertToPixmap' ones. Remember: the image and the original context share the drawing RAM.
There are a number of functions to display all or part of an image in the current context:
void GrImageDisplay(int x,int y, GrImage *i); void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i); void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2, GrImage *p); void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p); void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p);
'GrImageDisplay' display the whole image using 'x', 'y' like the upper left corner in the current context. 'GrImageDisplayExt' display as much as it can (repiting the image if necesary) in the rectangle defined by 'x1', 'y1' and 'x2', 'y2'.
'GrImageFilledBoxAlign' is a most general funtion (really the later two call it) display as much as it can in the defined rectangle using 'xo', 'yo' like the align point, it is the virtual point in the destination context (it doesn't need to be into the rectangle) with that the upper left image corner is aligned.
'GrImageHLineAlign' and 'GrImagePlotAlign' display a row segment or a point of the image at 'x' 'y' position using the 'xo', 'yo' allign point.
The most usefull image funtions are these:
GrImage *GrImageInverse(GrImage *p,int flag); GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight);
'GrImageInverse' creates a new image object, flipping 'p' left-right or top-down as indicated by 'flag' that can be:
#define GR_IMAGE_INVERSE_LR 0x01 /* inverse left right */ #define GR_IMAGE_INVERSE_TD 0x02 /* inverse top down */
'GrImageStretch' creates a new image stretching 'p' to 'nwidth' by 'nheight'.
To destroy a image objet when you don't need it any more use:
void GrImageDestroy(GrImage *i);
* (at the end of More Graphics primitives)
A efficient form to get/put pixels from/to a context can be achieved using the next functions:
const GrColor *GrGetScanline(int x1,int x2,int yy); const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy); void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op);
The 'Get' functions return a pointer to a static GrColor pixel array (or NULL if they fail) with the color values of a row ('yy') segment ('x1' to 'x2'). 'GrGetScanline' uses the current context. 'GrGestScanlineC' uses the context 'ctx' (that can be NULL to refer to the current context). Note that the output is only valid until the next GRX call.
'GrPutScanline' puts the GrColor pixel array 'c' on the 'yy' row segmet defined by 'x1' to 'x2' in the current context using the 'op' operation. 'op' can be any of 'GrWRITE', 'GrXOR', 'GrOR' 'GrAND' or 'GrIMAGE'. Data in 'c' must fit 'GrCVALUEMASK' otherwise the results are implementation dependend. So you can't supply operation code with the pixel data!.