Working with GIF images in Delphi

Need to display an animated GIF image in a Delphi application?

Working with GIF images in Delphi
Working with GIF images in Delphi.

Need to display an animated GIF image in a Delphi application? Even though Delphi does not natively support GIF image files formats (like BMP or JPEG) there are a few great (free source) components available on the Net, which add the ability to display and manipulate GIF images at run as well as at design time to any Delphi application.

Natively, Delphi supports BMP, ICO, WMF and JPG images - these can be loaded into a graphic-compatible component (such as TImage) and used in an application.

Note: As of Delphi version 2006 GIF format is supported by the VCL. To use animated GIF images you would still need a third-party control.

GIF - Graphics Interchange Format

GIF is the most widely supported (bitmap) graphics format on the Web, both for still images and for animations.

Using in Delphi

Natively, Delphi (until version 2007) does not support GIF images, due to some legal copyright issues. What this means, is that when you drop a TImage component on a form, use the Picture Editor (click the ellipsis button in the Value column for properties, such as the Picture property of TImage) to load an image into the TImage, you will not have an option to load GIF images.

Fortunately, there are a few third-party implementation on the Internet that provide full support for the GIF format:

  • TGIFImage[1] - free with source (a version of Anders Melander's TGIFImage ported to Delphi 7). Full TGraphic implementation of the GIF graphics format. Reads, writes and displays animated and transparent GIFs and can convert to and from any format supported by TGraphic (e.g TBitmap, TJPEGImage, TIcon, TMetaFile etc.). Implements the complete GIF87a and GIF89a specification and most common GIF extensions. Advanced features include:
    • Integrates with TPicture to add GIF support to the TImage, TOpenPictureDialog and TSavePictureDialog components. Also works at design time.
    • Imports images with more than 256 colors using color quantization and 6 different dithering methods (e.g. floyd s!teinberg).
    • Multi threaded drawing engine.
    • GIF optimizer reduces the size of your GIFs.
    • GIF to AVI and AVI to GIF converter.
  • GraphicEx image library - an addendum to Delphi's Graphics.pas to enable your application to load many common image formats. This library is primarily designed to load images as background (buttons, forms, toolbars) and textures (DirectX, OpenGL) or for image browsing and editing purposes as long as you don't need to save images. Currently only TTargaGraphic also supports saving an image. GraphicEx is open source under the Mozilla Public License (MPL).
    That's about it. Now all you have to do, is to download one of the components, and start using gif images in your applications.
    You can, for example:
    mla apa chicago
    Your Citation
    Gajic, Zarko. "Working with GIF images in Delphi." ThoughtCo, Jul. 18, 2011, Gajic, Zarko. (2011, July 18). Working with GIF images in Delphi. Retrieved from Gajic, Zarko. "Working with GIF images in Delphi." ThoughtCo. (accessed January 22, 2018).