<Start> <Intro> <Install> <Legal> <Screen> <Buffer> <Sprite> <Input> <Misc> <Debug> <Utes> <Author>
Images
Overview
Images are a convenient way for your program to load and display pictures such as backgrounds and titles. Two image file formats are supported
as of JLib version 1.5, PCX files and JLib's own file format: .jlb files. I probably won't be adding any more image functions, as it is a simple task
to convert images to and from PCX files using many public domain image utilities.
Developers Note: There may be some problems with .jlb files on machines with a different byte order than PC's. The most likely symptom is demo1 crashing. I suggest that non-PC users use PCX routines until I get this problem sorted out.
Image Functions
image *image_load_pcx(char *filename);
image *image_load_jlb(char *filename);
These two functions load PCX and .jlb files respectively, create space for storing them in an image record and return a pointer to that record. If
the file given as an argument can't be loaded then the image pointer is set to NULL. If the image was loaded correctly then the following macros
can be used to get information about the image:
IMG_WIDTH(image) Width of the image in pixels.
IMG_HEIGHT(image) Height of the image in pixels.
IMG_PALETTE(image) Returns a pointer to the images palette.
image *image_free(image *img_ptr);
This function releases the memory used by an image back to the operating system. Since images can potentially use a lot of memory, it is
recommended that you free the resources used by an image as soon as you are finished with it.
int image_save_jlb(char *filename,buffer_rec *buff,UBYTE *pal);
int image_save_jlb(char *filename,buffer_rec *buff,UBYTE *pal);
If you have a buffer containing some image data you would like to save as a .jlb or .PCX file you can save it with either of these functions. You
can then reload the buffer as an image using the appropriate image loading function.
void buff_blit_img_to(buffer_rec *dest,int x,int y,image *img,int ix1,int iy1,int ix2,int iy2);
void buff_blit_img_toNC(buffer_rec *dest,int x,int y,image *img,int ix1,int iy1,int ix2,int iy2);
This function takes as parameters a destination buffer dest and the position x, y in that buffer that you want the upper left corner of the image img blitted to. It also takes the 4 co-ordinates of the rectangle within the image that you would like copied into the buffer. The specified part of the image is copied into the buffer, with clipping performed if required.
Next Section: Micellaneous Functions
<Start> <Intro> <Install> <Legal> <Screen> <Buffer> <Sprite> <Input> <Misc> <Debug> <Utes> <Author>