GIF
Implements the GIF file format
You're viewing an older version of this page (#952). View the current version.
Interface
#include <codecogs/computing/graphics/formats/gif.h>
using namespace Computing::Graphics::Formats;
Overview
This module implements a class that allows you to load, save and manipulate non-animated GIF content. It also allows you to set various parameters of the image, like transparency, color table, and others.
The GIF format uses a lossless data compression algorithm to store its image data. The algorithm is a modification of the classic Lempel-Ziv-Welch (LZW) dictionary method, using variable code sizes during the compression process. The modified LZW algorithm is available as VariableLZW.
The GIF class can be used in a variety of circumstances, from extracting information about a GIF file, modifying a GIF and saving it, to creating a GIF image from scratch and saving it to disk.
Expand the following example to see how you can display information about a GIF.
Example showing information about a GIF file
The main input-output methods provided by this class are readFromBuffer and writeToBuffer, while the actual GIF manipulation is achived by changing the colorTable public variable, or by calling the setPixel method. The next example reads a GIF file from the disk, adds a border to it using the setPixel method and then writes the new GIF file to disk.
Example adding a border to a given GIF file
If you would like to create the whole GIF image from scratch, then you first need to make sure the canvas is set up properly, i.e. you need to set the dimensions of the GIF and call the createCanvas method to create the GIF's canvas on which you can draw. The next example draws a cross on a 50x50 canvas and saves it to disk.
Example showing how to manually create a GIF image
References
- LZW and GIF explained by Steve Blackstock, http://www.cis.udel.edu/~amer/CISC651/lzw.and.gif.explained.html
- "Compressed image file formats: JPEG, PNG, GIF, XBM, BMP" by John Miano, Chapter 12, http://books.google.com/books?id=_nJLvY757dQC&dq=Compressed+image+file+formats&printsec=frontcover&source=bn&hl=ro&ei=ImaPSuGxIsiK_Abyh5SvAg&sa=X&oi=book_result&ct=result&resnum=4#v=onepage&q=&f=false
- The Wikipedia page on the GIF format, http://en.wikipedia.org/wiki/Graphics_Interchange_Format
DECLARATION
RGBValue
(R, G, B) color triplet associated with a pixel of the image


