Ilib Image Library
The Ilib library is a portable set of routines for manipulating images. It has been successfully compiled and run on various UNIX platforms as well as Windows 95/98/NT (gcc, lcc-win32 and MS Visual C++). The source is 32-bit, so this will never be a 16-bit Windows application. It is intended to be independent of any windowing system or graphics file format.
API Documentation
Allocates a color to be used for drawing. (See ISetForeground).
Returns: IColor
Input Parameters:
- unsigned int red - red value (0-255)
- unsigned int green - green value (0-255)
- unsigned int blue - blue value (0-255)
Copies all or part of one image onto another image at a specified coordinate.
Returns: IError
Input Parameters:
- IImage source - source image
- IImage dest - destination image
- IGC gc - graphics context
- int src_x - x from source image
- int src_y - y from source image
- unsigned int width - width to copy
- unsigned int height - height to copy
- int dest_x - x coordinate on the destination image
- int dest_y - y coordinate on the destination image
Creates a graphic context for drawing on an image.
Returns: IGC
Input Parameters:
Create a blank (white) image of a specified width and height.
Returns: IImage
Input Parameters:
- unsigned int width - image width
- unsigned int height - image height
- unsigned int options - options flags (IOPTION_GREYSCALE, etc.)
Draws a line onto the image using the graphics context's current line style ( see ISetLineStyle).
Returns: IError
Input Parameters:
- IImage image - image
- IGC gc - graphics context
- int x1 - 1st coordinate
- int y1 - 1st coordinate
- int x2 - 2nd coordinate
- int y2 - 2nd coordinate
Draws a single point on the image.
Returns: IError
Input Parameters:
- IImage image - image
- IGC gc - graphics context
- int x - x coordinate
- int y - y coordinate
Draws a rectangle onto the image of the specified width and height using the graphic context's current line stlye ( see ISetLineStyle).
Returns: IError
Input Parameters:
- IImage image - image
- IGC gc - graphics context
- int x - x coordinate
- int y - y coordinate
- unsigned int width - width
- unsigned int height - height
Draws text onto the image at the specified coordinate. Non-ASCII charactes are supported by using escape sequences. For example, the copyright symbol is typically represented as "\033copyright;". See the font definition file to determine which characters are supported.
Note: the font is set with ISetFont.
Returns: IError
Input Parameters:
- IImage image - image
- IGC gc - graphics context
- int x - x coordinate (lower left of text)
- int y - y coordinate (lower left of text)
- char *text - pointer to text
- unsigned int len - length of text
Creates a duplicate of the original image.
Returns: IError
Input Parameters:
- IImage image - image to duplicate
Output Parameters:
- IImage *image_return - pointer to new image
Convert an IError value into text suitable for printing in an error message.
Returns: char *
Input Parameters:
Determine the type of image by the file extension.
Returns: IError
Input Parameters:
Output Parameters:
- IFileFormat *format_return - format of file
Fills a rectangle on the image using the graphics context's foreground color (see ISetForeground).
Returns: IError
Input Parameters:
- IImage image - image
- IGC gc - graphics context
- int x - x coordinate
- int y - y coordinate
- unsigned int width - width
- unsigned int height - height
Gets the pixel height of the font. (See ITextHeight for calculating the height of a multiline text.)
Returns: IError
Input Parameters:
Output Parameters:
- unsigned int *height_return - height in pixels of font
Frees a color no longer in use.
Returns: IError
Input Parameters:
Frees a font no longer in use.
Returns: IError
Input Parameters:
- IFont font - font to free
Frees a graphic context no longer in use.
Returns: IError
Input Parameters:
- IGC gc - graphics context
Frees the memory associated with an image that will not be used again.
Returns: IError
Input Parameters:
- IImage image - pointer to image
Loads a font from data passed in. This is identical to ILoadFontFromFile except the font data is passed in as an argument rather than a file. This allows the font to be embedded in the application rather than distributed as a separate file.
Returns: IError
Input Parameters:
- char *name - name to use for reference (filename)
- char **lines - font data (identical to file contents) as an array of character strings (one text line per array element terminated with a NULL element
Output Parameters:
- IFont *font_return - pointer to returned font
Load a font from file. Currently, only BDF font files can be used. BDF font files can be found at: ftp://ftp.x.org/pub/R6.1/xc/fonts/bdf/75dpi/. (BDF fonts are part of the X11 Window System developed at MIT and used on almost all UNIX workstations.)
Returns: IError
Input Parameters:
- char *name - name to use for reference (filename)
- char *path - path to font file
Output Parameters:
- IFont *font_return - returned font
Creates an image from an image file. Currently can only read raw PPM (IFORMAT_PPM), GIF (IFORMAT_GIF) and PNG (IFORMAT_PNG) files. The file is left open for the caller to close. (Note: you should set the file to binary mode on Win32 platforms.)
Returns: IError
Input Parameters:
- FILE *fp - file pointer
- IFileFormat format - output format (e.g. IFORMAT_GIF)
- IOptions options - options
Output Parameters:
- IImage *image_return - returned image on success
Sets the current drawing font for a graphics context. Subsequent calls to IDrawString will use the specified font.
Returns: IError
Input Parameters:
- IGC gc - graphics context
- IFont font - font
Set the foreground color of a graphics context. This will set the drawing color for drawing functions (IDrawLine, IFillRectangle, etc.)
Returns: IError
Input Parameters:
- IGC gc - graphics context
- IColor color - color
Sets the curret line drawing style for a graphics context. Currently support ILINE_SOLID (default) and ILINE_ON_OFF_DASH. (This applies to IDrawLine and IDrawRectangle.)
Returns: IError
Input Parameters:
- IGC gc - graphics context
- ILineStyle line_style - line style
Sets the line drawing with for a graphics context. (This applies to IDrawLine and IDrawRectangle.)
Returns: IError
Input Parameters:
- IGC gc - graphics context
- unsigned int line_width - line width
Set the transparent color of the image. This is only relevant to images that are written to either GIF or XPM formats.
Returns: IError
Input Parameters:
- IImage image - image
- IColor color - color
Determines the width & height (in pixels) of the given text for the specified font. (useful for multiline text)
Returns: IError
Input Parameters:
- IGC gc - graphics context
- IFont font - font
- char *text - text
- unsigned int len - length of text
Output Parameters:
- unsigned int *width_return - width in pixels of text
- unsigned int *height_return - height in pixels of text
Determines the height (in pixels) of the given text for the specified font. This is useful for multiline text.
Returns: IError
Input Parameters:
- IGC gc - graphics context
- IFont font - font
- char *text - text
- unsigned int len - length of text
Output Parameters:
- unsigned int *height_return - height in pixels of text
Determines the length (in pixels) of the given text for the specified font.
Returns: IError
Input Parameters:
- IGC gc - graphics context
- IFont font - font
- char *text - text
- unsigned int len - length of text
Output Parameters:
- unsigned int *width_return - width in pixels of text
Writes an image to a file. Currently supports writing PPM (IFORMAT_PPM), XPM (IFORMAT_XPM), GIF (IFORMAT_GIF), and PNG (IFORMAT_PNG) formats. The file is left open for the caller to close. (Note: you should set the file to binary mode on Win32 platforms.)
Returns: IError
Input Parameters:
- FILE *fp - file pointer
- IImage image - image
- IFileFormat format - output format (e.g. IFORMAT_XPM)
- IOptions options - options (e.g. IOPTION_INTERLACED)