ImageMan's fundamental mission is to allow you to easily display images from your application. Using ImageMan to fulfill this basic mission consists of a handful of simple steps:
ImgOpenSolo opens an image and returns a handle to be used in all subsequent ImageMan function calls pertaining to this image. ImgGetInfo returns to your application the image's pertinent data, including any special flags set for this image by ImageMan. ImgGetPalette gives you a palette that you can select into your device context before drawing. ImgDrawImage outputs the image to your display. ImgClose closes the image. Here's a simple code fragment (without error checking) which opens an image, draws it on a device context (hDC), and closes the image:
.
.
.
hImage = ImgOpenSolo("plane.pcx" , NULL);
lpbi = ImgGetInfo(hImage, &flags)
rect.left = rect.top = 0;
rect.right = lpbi->bmiHeader.biWidth-1;
rect.bottom = lpbi->bmiHeader.biHeight-1;
hPal = ImgGetPalette(hImage);
SelectPalette(hDC, hPal, FALSE);
RealizePalette(hDC);
ImgDrawImage(hImage, hDC, &rect, NULL);
ImgClose(hImage);
.
.
.
In this example, the image is drawn at (0,0) on the device context hDC, and is drawn at its full size (note that if the destination rectangle was not the image's full size, ImageMan automatically scales the image to fit the destination).
Although this example illustrates how ImageMan is used, it is hardly general; a more complete function for drawing an image might appear as follows:
void DrawAnImage(LPSTR lpFileName, HANDLE hDC, LPRECT lpDest)
{
HANDLE hImage, hPal;
int status, flags;
LPBITMAPINFO lpbi;
hImage = ImgOpenSolo(lpFileName, NULL);
if( hImage ) {
lpbi = ImgGetInfo(hImage, &flags);
hPal = ImgGetPalette(hImage);
SelectPalette(hDC, hPal, FALSE);
RealizePalette(hDC);
status = ImgDrawImage(hImage, hDC, lpDest, NULL);
ImgClose(hImage);
} else
ImgErrBox( NULL ); // Display Messagebox with Error description
}
Here you can see the power and flexibility of an object-oriented interface; ImageMan automatically recognizes all supported image file formats, so your function doesn't need to know what type you're working with, or even which image formats are supported by ImageMan. This unique architecture allows ImageMan to support new file formats by simply adding a DIL (dynamic imaging library) to the system to support each format; your application doesn't ever need to change to support new formats, they just magically appear!
The previous code fragment is merely a sample to illustrate how you might use ImageMan; in most cases, you will not want to close an image until you're sure you won't want to draw or print it again.
© 1995-2004 Data Techniques, Inc. All rights reserved.