ImageMan DLL Suite Version 8Submit feedback on this topic   

Scaling Images

Although the ImgDrawImage function will scale any image to any requested destination rectangle, this alone isn't always enough to give your application the performance it needs. For maximum performance, what you really need is to have a bitmap that's the exact size of the output destination this allows the image to be drawn without any scaling whatsoever. ImageMan lets you easily accomplish this through the use of the ImgCopy function. With ImgCopy, you can scale any raster image to any size (and very quickly, too). The result is returned to you in the form of a new ImageMan image handle, which you can then manipulate as you would any ImageMan image (note that this gives you both the original and the scaled image to work with). The following example shows how you might generate a small (100x100) thumbnail image from a much-larger image:

.

.

hImage2 = ImgCopy(hImage, 100, 100, NULL, COPY_DEL);

.

.

 

That's all there is to it. Note that if the original image is never loaded (i.e., the application hasn't called ImgLoad or any of the functions which would cause the image to be loaded), the scaled copy of the image is created without the source image ever being loaded entirely in memory. This is extremely useful for making reduced-resolution copies of very large images. See the explanation of the ImgCopy function in the reference section for details.

 

Another use for the ImgCopy command is copying a portion of an existing image. In this case, you would set the lpSrc parameter of the ImgCopy function to represent the portion of the image you wish to extract. As an example, the following line of code extracts the top left 100x100 pixels of the source image into an image that is 100x100 pixels in size:

 

srcRect.left = srcRect.top = 0;

srcRect.right = srcRect.bottom = 99;

hImage2 = ImgCopy(hImage, 100, 100, &srcRect, COPY_DEL)

 

 

 


© 1995-2004 Data Techniques, Inc. All rights reserved.