| Home | ![]() |
The QtICOImageFormat class provides support for reading and writing .ICO files. More...
#include <qticoimageformat.h>
The QtICOImageFormat class provides support for reading and writing .ICO files.
The QtICOImageFormat class provides static functions for reading and writing .ICO files. It also provides a static function to install the ICO format as a QImageIO format handler, making it possible to load and save .ICO files using standard QImage functions.
The ICO format can hold multiple images. The read() function reads all the icons in a file as a QValueList of QImages:
QValueList<QImage> icons = QtICOImageFormat::read("myicons.ico");
The resulting images will all be 32-bit images, where the masked section of the original icons is transparent in the corresponding QImages.
Writing more than one QImage to a file is easily achieved by packing a list with QImage objects then using the write() function:
QImage image1, image2;
QValueList<QImage> icons;
icons << image1 << image2;
QtICOImageFormat::write("myicons.ico", icons);
The first image becomes the .ICO file's default image.
The ICO image format can be installed as a QImageIO handler in the following way:
QtICOImageFormat::installIOHandler();
This will enable you to use normal QImage and QPixmap methods to read and write icons. For example:
myButton->setPixmap(QPixmap("myicons.ico"));
myPixmap.save("myicon.ico", "ICO");
When using this method to read in icons, only the first icon in the .ICO file is used.
See also
To register this plugin, simply call this function in your application's initialization code.
Example: icobrowser.cpp.
Each image has an alpha channel that represents the mask from the corresponding icon.
See also write().
Reads all the icons from the file specified by fileName, and returns them as a list of QImage objects.
Each image has an alpha channel that represents the mask from the corresponding icon.
See also write().
The first image in the list is stored as the first icon in the device, and is therefore used as the default icon by applications. The alpha channel of each image is converted to a mask for each corresponding icon.
See also read().
Example: icobrowser.cpp.
Writes all the QImages in the images list to the file specified by fileName. Returns true if the images are written successfully; otherwise returns false.
The first image in the list is stored as the first icon in the file, and is therefore used as the default icon by applications. The alpha channel of each image is converted to a mask for each corresponding icon.
See also read().
This file is part of the Qt Solutions.
Copyright © 2003-2006
Trolltech. All Rights Reserved.
| Copyright © 2003-2006 Trolltech | Trademarks | Qt Solutions
|