Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
Implementing Extended FlashPix Support
The FlashPix file format was developed through the combined efforts of Eastman Kodak Company, Microsoft Corporation, Hewlett-Packard Company and Live Picture, Inc. It combines the best features of existing image formats with the benefits associated with object orientation to make using digital color images easier.
The format of a FlashPix file is based on compound object storage, which allows storage of various kinds of data. A FlashPix file may consist of several "pages" where each "page" has storage for a source image, non-image data in the form of comments, transform data, and a stamp or thumbnail. Each image is stored as an entire multi-resolution hierarchy where each resolution in the hierarchy differs from the next highest resolution by a factor of 2 in the x dimension and in the y dimension. LEADTOOLS treats the non-image data stored in FlashPix files as comments. Comments are used to store information pertaining to the image, not actual pixel data. This information may include image title, image subject, camera manufacturer, scan software version number, and so forth. In addition to the image itself, FlashPix files store transform information, such as rotation, shearing, and color manipulation, among others. This data indicates transformations which may be performed on the source image. By storing the transforms, the source image stays in its original state and is transformed, using the stored transforms, at your discretion, only when the file is loaded. A stamp, or thumbnail, provides a small bitmap representation of a FlashPix image. By default, LEADTOOLS saves a stamp of size 96 x 96. This is the largest stamp allowed, even if the user sets larger dimensions.
The FlashPix extended support extends the input/output functionality in LEADTOOLS by providing increased versatility in the handling of color and grayscale images by taking advantage of the complete FlashPix file structure. FlashPix is a newly emerging file format sponsored by Kodak, Microsoft, Hewlett-Packard, and many other industry leaders. LEAD has been asked by this industry group to add the format to LEADTOOLS, and to join the group in supporting this new image format technology. Features of the extended support include "Working with non-image data", "Loading and saving a portion of an image", "Working with thumbnail images in a FlashPix file", and "Working with transformation parameters in an existing FlashPix file" and are discussed in more detail below.
For more information about required files, refer to Files To Be Included With Your Application.
Further details of the new extended FlashPix features are given below:
Working with non-image data
LEADTOOLS treats non-image data as comments. These comments store a variety of information concerning an image. You set comments in a FlashPix file one at a time, using L_SetComment. Once all comments are set, the comments are saved using any function which saves files, such as L_SaveFile or L_SaveBitmap when creating a new file, or L_WriteFileCommentExt when changing a comment in an existing file. L_SetComment, by itself, does not write a comment to a file, it prepares the values for the next save.
Comments are read directly from the file, without having to load the image. With the LEADTOOLS FlashPix extended support you have the ability to read a group of comments such as the "Summary Information Group" (CMNT_FPXSUMMARYINFORMATION), multiple groups of comments such as the "File Source Group" and the "Film Description Group" (CMNT_FPXFILESOURCEGROUP | CMNT_FPXFILMDESCRIPTIONGROUP), or all comments (CMNT_ALL). More information concerning comments and groups of comments may be found in FlashPix File Comments.
Retrieving one or more groups of comments is acheived through the use of L_GetFileCommentSize and L_ReadFileCommentExt, which retrieve the size, in bytes, of the desired comments, and read the comments, respectively. An example of this can be seen under "Example" in the L_ReadFileCommentExt entry. This allows you to retrieve a large number of comments with one function call instead of having to make a separate function call for each comment.
It is also possible to retrieve individual comments such as the image title (CMNT_FPXTITLE), but this must be done using the L_ReadFileComment function. An example of retrieving a single FlashPix comment may be seen in "Example" under the L_GetFileCommentSize entry. It is important to note that 1) comments must be set individually and saved when creating a new file, but can be changed in an existing file using L_WriteFileCommentExt in this package, as outlined above and 2) the L_GetFileCommentSize and L_ReadFileCommentExt only work for FlashPix files in this version.
Loading and saving a portion of a FlashPix file
Loading and processing large images can be very time consuming. Occasionally you may only need to work with a portion of an image. Using L_LoadFileTile you may load only a portion of a FlashPix image by designating the starting position, width and height of the desired region*. This allows you to load only part of an image, without having to load the entire image. Once you are finished with the image tile, you may save that tile using L_SaveFileTile.
Working with thumbnail images in a FlashPix file
A thumbnail, or stamp, is a small bitmap representation of a FlashPix image. Reading a thumbnail image stored in a FlashPix file and loading it into a bitmap may be performed using L_ReadFileStamp. To save a stamp into an already existing FlashPix file, use L_WriteFileStamp. The stamp will be written to the page designated in the SAVEFILEOPTION structure. If that page already has a stamp, it will be overwritten; if the page does not exist, the stamp will be written to the last page present in the file. If the file to which the stamp is being written does not exist, an error will be returned.
Working with transformation parameters in an existing FlashPix file
Images may be transformed by rotation, linear translation, shearing, contrast stretching, sharpening, and blurring, among others. In FlashPix files these transforms may be stored with the image itself. This allows the source image to be unchanged, and the transforms to describe the proposed change. By storing both the transforms and the original image, you can elect to load the image either in its original state or in its transformed state. To help you decide how to load the image, L_ReadFileTransforms reads the transforms stored in the image so that you may find out what transform(s) are present. There are four options for loading the image: unchanged, color transforms only, view transforms only and all transforms. If you elect to load the image unchanged, you must make sure both the ELO_IGNOREVIEWTRANSFORMS and the ELO_IGNORECOLORTRANSFORMS flags have been set in the Flags data member of LOADFILEOPTION structure before loading the file. (Note: By setting these flags you are telling the system to ignore the transforms.) To load the image with only the effects of the color transforms incorporated, you must set the ELO_IGNOREVIEWTRANSFORMS flag, and clear the ELO_IGNORECOLORTRANSFORMS flag. To load the image with only the effects of the viewing transforms incorporated, you must set the ELO_IGNORECOLORTRANSFORMS flag and clear the ELO_IGNOREVIEWTRANSFORMS flag. Finally, to load the image with both the color transforms and the view transforms incorporated, clear both the ELO_IGNOREVIEWTRANSFORMS and the ELO_IGNORECOLORTRANSFORMS flags. An example of loading an image using each of these four options may be seen in "Example" under L_LoadFile.
To store transforms in a FlashPix file, set the appropriate variables in an instance of FILETRANSFORMS to the desired values and use L_WriteFileTransforms to write them to the FlashPix file. For an example using both L_ReadFileTransforms and L_WriteFileTransforms, see "Example" under the L_ReadFileTransforms entry. Further information concerning transforms may be found in FILETRANSFORMS.
* Regions are not supported on Windows CE.
Also Refer to: