graphics

Name

graphics —

Synopsis



GR_GC_ID    GrNewGC                         (void);
GR_GC_ID    GrCopyGC                        (GR_GC_ID gc);
void        GrGetGCInfo                     (GR_GC_ID gc,
                                             GR_GC_INFO *gcip);
void        GrDestroyGC                     (GR_GC_ID gc);
void        GrLine                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x1,
                                             GR_COORD y1,
                                             GR_COORD x2,
                                             GR_COORD y2);
void        GrPoint                         (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y);
void        GrPoints                        (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);
void        GrRect                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height);
void        GrFillRect                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height);
void        GrPoly                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);
void        GrFillPoly                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);
void        GrEllipse                       (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry);
void        GrFillEllipse                   (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry);
void        GrArc                           (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry,
                                             GR_COORD ax,
                                             GR_COORD ay,
                                             GR_COORD bx,
                                             GR_COORD by,
                                             int type);
void        GrArcAngle                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry,
                                             GR_COORD angle1,
                                             GR_COORD angle2,
                                             int type);
void        GrSetGCForeground               (GR_GC_ID gc,
                                             GR_COLOR foreground);
void        GrSetGCBackground               (GR_GC_ID gc,
                                             GR_COLOR background);
void        GrSetGCUseBackground            (GR_GC_ID gc,
                                             GR_BOOL flag);
void        GrSetGCMode                     (GR_GC_ID gc,
                                             int mode);
void        GrSetGCFont                     (GR_GC_ID gc,
                                             GR_FONT_ID font);
void        GrGetGCTextSize                 (GR_GC_ID gc,
                                             void *str,
                                             int count,
                                             int flags,
                                             GR_SIZE *retwidth,
                                             GR_SIZE *retheight,
                                             GR_SIZE *retbase);
void        GrReadArea                      (GR_DRAW_ID id,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_PIXELVAL *pixels);
void        GrArea                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             void *pixels,
                                             int pixtype);
void        GrCopyArea                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_DRAW_ID srcid,
                                             GR_COORD srcx,
                                             GR_COORD srcy,
                                             int op);
void        GrBitmap                        (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_BITMAP *imagebits);
void        GrFreeImage                     (GR_IMAGE_ID id);
void        GrGetImageInfo                  (GR_IMAGE_ID id,
                                             GR_IMAGE_INFO *iip);
void        GrDrawImageFromFile             (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             char *path,
                                             int flags);
GR_IMAGE_ID GrLoadImageFromFile             (char *path,
                                             int flags);
void        GrDrawImageToFit                (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_IMAGE_ID imageid);
void        GrDrawImageBits                 (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_IMAGE_HDR *pimage);
void        GrText                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             void *str,
                                             GR_COUNT count,
                                             int flags);

Description

Details

GrNewGC ()

GR_GC_ID    GrNewGC                         (void);

Creates a new graphics context structure and returns the ID used to refer to it. The structure is initialised with a set of default parameters.

Returns : the ID of the newly created graphics context or 0 on error


GrCopyGC ()

GR_GC_ID    GrCopyGC                        (GR_GC_ID gc);

Creates a new graphics context structure and fills it in with the values from the specified already existing graphics context.

gc : the already existing graphics context to copy the parameters from
Returns : the ID of the newly created graphics context or 0 on error


GrGetGCInfo ()

void        GrGetGCInfo                     (GR_GC_ID gc,
                                             GR_GC_INFO *gcip);

Fills in the specified GR_GC_INFO structure with information regarding the specified graphics context.

gc : a graphics context
gcip : pointer to a GR_GC_INFO structure


GrDestroyGC ()

void        GrDestroyGC                     (GR_GC_ID gc);

Destroys the graphics context structure with the specified ID.

gc : the ID of the graphics context structure to destroy


GrLine ()

void        GrLine                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x1,
                                             GR_COORD y1,
                                             GR_COORD x2,
                                             GR_COORD y2);

Draws a line using the specified graphics context on the specified drawable from (x1, y1) to (x2, y2), with coordinates given relative to the drawable.

id : the ID of the drawable to draw the line on
gc : the ID of the graphics context to use when drawing the line
x1 : the X coordinate of the start of the line relative to the drawable
y1 : the Y coordinate of the start of the line relative to the drawable
x2 : the X coordinate of the end of the line relative to the drawable
y2 : the Y coordinate of the end of the line relative to the drawable


GrPoint ()

void        GrPoint                         (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y);

Draws a point using the specified graphics context at the specified position on the specified drawable.

id : the ID of the drawable to draw a point on
gc : the ID of the graphics context to use when drawing the point
x : the X coordinate to draw the point at relative to the drawable
y : the Y coordinate to draw the point at relative to the drawable


GrPoints ()

void        GrPoints                        (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);

Draws a set of points using the specified graphics context at the positions specified by the point table on the specified drawable.

id : the ID of the drawable to draw a point on
gc : the ID of the graphics context to use when drawing the point
count : the number of points in the point table
pointtable : pointer to a GR_POINT array which lists the points to draw


GrRect ()

void        GrRect                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height);

Draw the boundary of a rectangle of the specified dimensions and position on the specified drawable using the specified graphics context.

id : the ID of the drawable to draw the rectangle on
gc : the ID of the graphics context to use when drawing the rectangle
x : the X coordinate of the rectangle relative to the drawable
y : the Y coordinate of the rectangle relative to the drawable
width : the width of the rectangle
height : the height of the rectangle


GrFillRect ()

void        GrFillRect                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height);

Draw a filled rectangle of the specified dimensions and position on the specified drawable using the specified graphics context.

id : the ID of the drawable to draw the rectangle on
gc : the ID of the graphics context to use when drawing the rectangle
x : the X coordinate of the rectangle relative to the drawable
y : the Y coordinate of the rectangle relative to the drawable
width : the width of the rectangle
height : the height of the rectangle


GrPoly ()

void        GrPoly                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);

Draws an unfilled polygon on the specified drawable using the specified graphics context. The polygon is specified by an array of point structures. The polygon is not automatically closed- if a closed polygon is desired, the last point must be the same as the first.

id : the ID of the drawable to draw the polygon onto
gc : the ID of the graphics context to use when drawing the polygon
count : the number of points in the point array
pointtable : pointer to an array of points describing the polygon


GrFillPoly ()

void        GrFillPoly                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COUNT count,
                                             GR_POINT *pointtable);

Draws a filled polygon on the specified drawable using the specified graphics context. The polygon is specified by an array of point structures. The polygon is automatically closed- the last point need not be the same as the first in order for the polygon to be closed.

id : the ID of the drawable to draw the polygon onto
gc : the ID of the graphics context to use when drawing the polygon
count : the number of points in the point array
pointtable : pointer to an array of points describing the polygon


GrEllipse ()

void        GrEllipse                       (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry);

Draws the boundary of ellipse at the specified position using the specified dimensions and graphics context on the specified drawable.

id : the ID of the drawable to draw the ellipse on
gc : the ID of the graphics context to use when drawing the ellipse
x : the X coordinate to draw the ellipse at relative to the drawable
y : the Y coordinate to draw the ellipse at relative to the drawable
rx : the radius of the ellipse on the X axis
ry : the radius of the ellipse on the Y axis


GrFillEllipse ()

void        GrFillEllipse                   (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry);

Draws a filled ellipse at the specified position using the specified dimensions and graphics context on the specified drawable.

id : the ID of the drawable to draw the filled ellipse on
gc : the ID of the graphics context to use when drawing the ellipse
x : the X coordinate to draw the ellipse at relative to the drawable
y : the Y coordinate to draw the ellipse at relative to the drawable
rx : the radius of the ellipse on the X axis
ry : the radius of the ellipse on the Y axis


GrArc ()

void        GrArc                           (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry,
                                             GR_COORD ax,
                                             GR_COORD ay,
                                             GR_COORD bx,
                                             GR_COORD by,
                                             int type);

Draws an arc with the specified dimensions at the specified position on the specified drawable using the specified graphics context. The type specifies the fill type. Possible values include GR_ARC and GR_PIE.

id : the ID of the drawable to draw the arc on
gc : the graphics context to use when drawing the arc
x : the X coordinate to draw the arc at relative to the drawable
y : the Y coordinate to draw the arc at relative to the drawable
rx : the radius of the arc on the X axis
ry : the radius of the arc on the Y axis
ax : the X coordinate of the start of the arc relative to the drawable
ay : the Y coordinate of the start of the arc relative to the drawable
bx : the X coordinate of the end of the arc relative to the drawable
by : the Y coordinate of the end of the arc relative to the drawable
type : the fill style to use when drawing the arc


GrArcAngle ()

void        GrArcAngle                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE rx,
                                             GR_SIZE ry,
                                             GR_COORD angle1,
                                             GR_COORD angle2,
                                             int type);

Draws an arc with the specified dimensions at the specified position on the specified drawable using the specified graphics context. The type specifies the fill type. Possible values include GR_ARC and GR_PIE. This function requires floating point support, and is slightly slower than the GrArc() function which does not require floating point.

id : the ID of the drawable to draw the arc on
gc : the graphics context to use when drawing the arc
x : the X coordinate to draw the arc at relative to the drawable
y : the Y coordinate to draw the arc at relative to the drawable
rx : the radius of the arc on the X axis
ry : the radius of the arc on the Y axis
angle1 : the angle of the start of the arc
angle2 : the angle of the end of the arc
type : the fill style to use when drawing the arc


GrSetGCForeground ()

void        GrSetGCForeground               (GR_GC_ID gc,
                                             GR_COLOR foreground);

Changes the foreground colour of the specified graphics context to the specified colour.

gc : the ID of the graphics context to set the foreground colour of
foreground : the colour to use as the new foreground colour


GrSetGCBackground ()

void        GrSetGCBackground               (GR_GC_ID gc,
                                             GR_COLOR background);

Changes the background colour of the specified graphics context to the specified colour.

gc : the ID of the graphics context to set the background colour of
background : the colour to use as the new background colour


GrSetGCUseBackground ()

void        GrSetGCUseBackground            (GR_GC_ID gc,
                                             GR_BOOL flag);

Sets the flag which chooses whether or not the background colour is used when drawing bitmaps and text using the specified graphics context to the specified value.

gc : the ID of the graphics context to change the "use background" flag of
flag : flag specifying whether to use the background colour or not


GrSetGCMode ()

void        GrSetGCMode                     (GR_GC_ID gc,
                                             int mode);

Changes the drawing mode (SET, XOR, OR, AND, etc.) of the specified graphics context to the specified mode.

gc : the ID of the graphics context to set the drawing mode of
mode : the new drawing mode


GrSetGCFont ()

void        GrSetGCFont                     (GR_GC_ID gc,
                                             GR_FONT_ID font);

Sets the font to be used for text drawing in the specified graphics context to the specified font ID.

gc : the ID of the graphics context to set the font of
font : the ID of the font


GrGetGCTextSize ()

void        GrGetGCTextSize                 (GR_GC_ID gc,
                                             void *str,
                                             int count,
                                             int flags,
                                             GR_SIZE *retwidth,
                                             GR_SIZE *retheight,
                                             GR_SIZE *retbase);

Calculates the dimensions of the specified text string using the current font and flags in the specified graphics context. The count argument can be -1 if the string is null terminated.

gc : the graphics context
str : pointer to a text string
count : the length of the string
flags : text rendering flags (GR_TF*)
retwidth : pointer to the variable the width will be returned in
retheight : pointer to the variable the height will be returned in
retbase : pointer to the variable the baseline height will be returned in


GrReadArea ()

void        GrReadArea                      (GR_DRAW_ID id,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_PIXELVAL *pixels);

Reads the pixel data of the specified size from the specified position on the specified drawable into the specified pixel array. If the drawable is a window, the data returned will be the pixel values from the relevant position on the screen regardless of whether the window is obscured by other windows. If the window is unmapped, or partially or fully outside a window boundary, black pixel values will be returned.

id : the ID of the drawable to read an area from
x : the X coordinate to read the area from relative to the drawable
y : the Y coordinate to read the area from relative to the drawable
width : the width of the area to read
height : the height of the area to read
pixels : pointer to an area of memory to place the pixel data in


GrArea ()

void        GrArea                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             void *pixels,
                                             int pixtype);

Draws the specified pixel array of the specified size and format onto the specified drawable using the specified graphics context at the specified position. Note that colour conversion is currently only performed when using the GR_PF_RGB format, which is an unsigned long containing RGBX data.

id : the ID of the drawable to draw the area onto
gc : the ID of the graphics context to use when drawing the area
x : the X coordinate to draw the area at relative to the drawable
y : the Y coordinate to draw the area at relative to the drawable
width : the width of the area
height : the height of the area
pixels : pointer to an array containing the pixel data
pixtype : the format of the pixel data


GrCopyArea ()

void        GrCopyArea                      (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_DRAW_ID srcid,
                                             GR_COORD srcx,
                                             GR_COORD srcy,
                                             int op);

Copies the specified area of the specified size between the specified drawables at the specified positions using the specified graphics context and ROP codes. 0 is a sensible default ROP code in most cases.

id : the ID of the drawable to copy the area to
gc : the ID of the graphics context to use when copying the area
x : the X coordinate to copy the area to within the destination drawable
y : the Y coordinate to copy the area to within the destination drawable
width : the width of the area to copy
height : the height of the area to copy
srcid : the ID of the drawable to copy the area from
srcx : the X coordinate to copy the area from within the source drawable
srcy : the Y coordinate to copy the area from within the source drawable
op : the ROP codes to pass to the blitter when performing the copy


GrBitmap ()

void        GrBitmap                        (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_BITMAP *imagebits);

Draws the monochrome bitmap data provided in the bitmaptable argument at the specified position on the specified drawable using the specified graphics context. Note that the bitmap data should be an array of aligned 16 bit words. The usebackground flag in the graphics context specifies whether to draw the background colour wherever a bit value is zero.

id : the ID of the drawable to draw the bitmap onto
gc : the ID of the graphics context to use when drawing the bitmap
x : the X coordinate to draw the bitmap at relative to the drawable
y : the Y coordinate to draw the bitmap at relative to the drawable
width : the width of the bitmap
height : the height of the bitmap
imagebits : 


GrFreeImage ()

void        GrFreeImage                     (GR_IMAGE_ID id);

Destroys the specified image buffer and reclaims the memory used by it.

id : ID of the image buffer to free


GrGetImageInfo ()

void        GrGetImageInfo                  (GR_IMAGE_ID id,
                                             GR_IMAGE_INFO *iip);

Fills in the specified image information structure with the details of the specified image buffer.

id : ID of an image buffer
iip : pointer to a GR_IMAGE_INFO structure


GrDrawImageFromFile ()

void        GrDrawImageFromFile             (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             char *path,
                                             int flags);

Loads the specified image file and draws it at the specified position on the specified drawable using the specified graphics context. The width and height values specify the size of the image to draw- if the actual image is a different size, it will be scaled to fit. The image type is automatically detected using the magic numbers in the image header (ie. the filename extension is irrelevant). The currently supported image types include GIF, JPEG, Windows BMP, PNG, XPM, and both ascii and binary variants of PBM, PGM, and PPM. However the image types supported by a particular server depend on which image types were enabled in the server configuration at build time.

id : the ID of the drawable to draw the image onto
gc : the ID of the graphics context to use when drawing the image
x : the X coordinate to draw the image at relative to the drawable
y : the Y coordinate to draw the image at relative to the drawable
width : the maximum image width
height : the maximum image height
path : string containing the filename of the image to load
flags : flags specific to the particular image loader


GrLoadImageFromFile ()

GR_IMAGE_ID GrLoadImageFromFile             (char *path,
                                             int flags);

Loads the specified image file into a newly created server image buffer and returns the ID of the buffer. The image type is automatically detected using the magic numbers in the image header (ie. the filename extension is irrelevant). The currently supported image types include GIF, JPEG, Windows BMP, PNG, XPM, and both ascii and binary variants of PBM, PGM, and PPM. However the image types supported by a particular server depend on which image types were enabled in the server configuration at build time.

path : string containing the filename of the image to load
flags : flags specific to the particular image loader
Returns : ID of the image buffer the image was loaded into


GrDrawImageToFit ()

void        GrDrawImageToFit                (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_SIZE width,
                                             GR_SIZE height,
                                             GR_IMAGE_ID imageid);

Draws the image from the specified image buffer at the specified position on the specified drawable using the specified graphics context. The width and height values specify the size of the image to draw- if the actual image is a different size, it will be scaled to fit.

id : the ID of the drawable to draw the image onto
gc : the ID of the graphics context to use when drawing the image
x : the X coordinate to draw the image at relative to the drawable
y : the Y coordinate to draw the image at relative to the drawable
width : the maximum image width
height : the maximum image height
imageid : the ID of the image buffer containing the image to display


GrDrawImageBits ()

void        GrDrawImageBits                 (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             GR_IMAGE_HDR *pimage);

Draws the image contained in the specified image structure onto the specified drawable at the specified coordinates using the specified graphics context.

id : the ID of the drawable to draw the image onto
gc : the ID of the graphics context to use when drawing the image
x : the X coordinate to draw the image at relative to the drawable
y : the Y coordinate to draw the image at relative to the drawable
pimage : pointer to the image structure


GrText ()

void        GrText                          (GR_DRAW_ID id,
                                             GR_GC_ID gc,
                                             GR_COORD x,
                                             GR_COORD y,
                                             void *str,
                                             GR_COUNT count,
                                             int flags);

Draws the specified text string at the specified position on the specified drawable using the specified graphics context and flags. The default flags specify ASCII encoding and baseline alignment.

id : the ID of the drawable to draw the text string onto
gc : the ID of the graphics context to use when drawing the text string
x : the X coordinate to draw the string at relative to the drawable
y : the Y coordinate to draw the string at relative to the drawable
str : the text string to draw
count : the number of characters (not bytes) in the string
flags : flags specifying text encoding, alignment, etc.