tga.c - implements reading and writing targa files, uses io layer.
io_glue *ig = io_new_fd( fd ); i_img *im = i_readtga_wiol(ig, -1); // no limit on how much is read // or io_glue *ig = io_new_fd( fd ); return_code = i_writetga_wiol(im, ig);
tga.c implements the basic functions to read and write portable targa files. It uses the iolayer and needs either a seekable source or an entire memory mapped buffer.
Some of these functions are internal.
Convert bits per pixel into bytes per pixel
bpp - bits per pixel
Convert bits per pixel and the number of attribute bits into channels in the image
bpp - bits per pixel attr_bit_count - number of attribute bits
Unpacks bytes into colour structures, for 2 byte type the first byte coming from the file will actually be GGGBBBBB, and the second will be ARRRRRGG. "A" represents an attribute bit. The 3 byte entry contains 1 byte each of blue, green, and red. The 4 byte entry contains 1 byte each of blue, green, red, and attribute.
buf - pointer to data bytepp - bytes per pixel val - pointer to color to store to
Packs a colour into an array of bytes, for 2 byte type the first byte will be GGGBBBBB, and the second will be ARRRRRGG. "A" represents an attribute bit. The 3 byte entry contains 1 byte each of blue, green, and red. The 4 byte entry contains 1 byte each of blue, green, red, and attribute.
buf - destination buffer bitspp - bits per pixel val - color to pack
Helper function for rle compressor to find the next triple repeat of the same pixel value in buffer.
buf - buffer length - number of pixel values in buffer bytepp - number of bytes in a pixel value
Helper function for rle compressor to find the length of a span where the same pixel value is in the buffer.
Unpacks the header structure into from buffer and stores in the header structure.
header - header structure headbuf - buffer to unpack from
Packs header structure into buffer for writing.
header - header structure headbuf - buffer to pack into
Reads pixel number of pixels from source s into buffer buf. Takes care of decompressing the stream if needed.
s - data source buf - destination buffer pixels - number of pixels to put into buffer
Writes pixels from buf to destination s. Takes care of compressing if the destination is compressed.
s - data destination buf - source buffer pixels - number of pixels to put write to destination
Reads the colormap from a tga file and stores in the paletted image structure.
ig - iolayer data source img - image structure bytepp - bytes per pixel colourmaplength - number of colours in colourmap
Stores the colormap of an image in the destination ig.
ig - iolayer data source img - image structure bitspp - bits per pixel in colourmap colourmaplength - number of colours in colourmap
Read in an image from the iolayer data source and return the image structure to it. Returns NULL on error.
ig - io_glue object length - maximum length to read from data source, before closing it -1 signifies no limit.
Writes an image in targa format. Returns 0 on error.
img - image to store ig - io_glue object
Arnar M. Hrafnkelsson <addi@umich.edu>
Imager(3)
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.