Using the low-level functions involves a little more setup than does calling ImgXWriteDIB, but offers a finer degree of control over the export process. You should use the low-level functions if:
Using the low-level functions involves the following steps:
Setting up an Option Block - if necessary.
Getting pointers to the BITMAPINFO structure and the image's raster data.
Call the ImgXFileDialog function to prompt the user for a filename - if necessary.
Call ImgXBeginWrite or ImgXBeginWriteMem to start the export process.
Call ImgXWriteBlock one or more times to write the image data.
Call ImgXEndWrite or ImgXEndWriteMem to finish writing the image.
Delete the Option block if you created one.
Lets look at a short sample which exports an image to a file:
HANDLE hJob;
XINFO xInfo;
...
// lpBitmapInfo points to a BITMAPINFO structure
// lpRasterData points to our image data in DIB format
// xInfo has been initialized
hJob = ImgXBeginWrite( "sample.pcx", lpBitmapInfo,NULL, &xInfo );
// nLines is the # of lines in the buffer pointed to by lpRasterData
ImgXWriteBlock( hJob, nLines, lpRasterData, &xInfo );
ImgXEndWrite( hJob, &xInfo );
...
To simplify the code we have left out any error checking. In a real application it would be very important to check the return values from all three function calls .
To allow the user to select a filename you could change that code to look like this:
HANDLE hJob;
XINFO xInfo;
HANDLE hOptBlk;
...
hOptBlk = ImgXFileDialog( NULL, hWnd );
© 1995-2004 Data Techniques, Inc. All rights reserved.