msicon.c - functions for working with .ICO files.
// reading int error; ico_reader_t *file = ico_reader_open(ig, &error); if (!file) { char buffer[100]; ico_error_message(error, buffer, sizeof(buffer)); fputs(buffer, stderr); exit(1); } int count = ico_image_count(file); for (i = 0; i < count; ++i) { ico_image_t *im = ico_image_read(file, index); printf("%d x %d image %d\n", im->width, im->height, im->direct ? "direct" : "paletted"); ico_image_release(im); } ico_reader_close(file);
This is intended as a general interface to reading MS Icon files, and is written to be independent of Imager, even though it is part of Imager. You just need to supply something that acts like Imager's io_glue.
It relies on icon images being generally small, and reads the entire image into memory when reading.
Parameters:
io_glue *ig - an Imager IO object. This must be seekable.
int *error - pointer to an integer which an error code will be returned in on failure.
// number of images in the file count = ico_image_count(file);
// type of file - ICON_ICON for icon, ICON_CURSOR for cursor type = ico_type(file);
Read an image from the file given it's index.
Release an image structure returned by ico_image_read.
Releases the read file structure.
io_glue *ig - an Imager IO object. This only needs to implement writing for ico_write()
ico_image_t *images - array of images to be written.
int image_count - number of images
int type - must be ICON_ICON or ICON_CURSOR
int *error - set to an error code on failure.
Returns non-zero on success.
Converts an error code into an error message.
Reads packed data from a stream, unpacking it.
Reads the palette data for an icon image.
Reads 32 bit image data.
Reads 24 bit image data.
Reads 8 bit image data.
Reads 4 bit image data.
Reads 1 bit image data.
Reads the AND mask from an icon image.
Check each image to make sure it can go into an icon file.
Calculate how much space the icon takes up in the file.
Pack numbers given a format to a stream.
Write the palette for an icon.
Write the BITMAPINFOHEADER for an icon image.
Write 32-bit image data to the icon.
Write 8 bit image data.
Write 4 bit image data.
Write 1 bit image data.
Write the AND mask.
Tony Cook <tonyc@cpan.org>
$Revision$
To install Imager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Imager
CPAN shell
perl -MCPAN -e shell install Imager
For more information on module installation, please visit the detailed CPAN module installation guide.