Jul 07, 2010 What I want is to copy TImageList 32-bit PNG image (with alpha transparency) to blank TImage. ImageList1 contains 32-bit PNG images. Image1 is just a blank TImage.
I have a form in Delphi 6 which consists of a TImage and TImageList. My TImageList consists of various icons, and I'd like to put one of them in the TImage so that it is displayed on the form - for example the first image in the list (0).
How to I copy an image from a TImageList to a TImage?
I want to then save the TImage as a PNG image file, that I can do using some demo code I've obtained elsewhere, however if anyone can show me a better of doing this, I'd be most grateful! Cheers.
Matt.
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 graphics-compatible component (such as TImage) and used in an application.
It's important to note that, 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.
GIFs--or Graphics Interchange Formats--are 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 implementations on the Internet that provide full support for the GIF format:
- TGIFImage: 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-Steinberg).
- 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:
- Store GIF images in a database table. You'll need the GIF image's 'magic numbers.'
- Show GIF graphics as Glyph on a SpeedButton.
- Store GIF graphics and an HTML file as a resource inside am exe.