How to Scale DIBs

Home » Imaging Toolkit » How to Scale DIBs
Imaging Toolkit No Comments

Developers can use the ScaleDIB function to change the DPI or size in pixels of an image. The most common scenario that this is used to change a faxed image which is saved with fax DPI (204 X 98 or 204 X 196) to an equal X and Y resolution, such as 200 X 200 DPI.

The ScaleDIB method operates using the pixel size of the image. Developers first have to scale the image to the desired size in terms of pixels and then change the DPI of the image. Since the DIB is based on the metric system, developers have to convert the DPI to pixel per meter to set the biXPelsPerMeter and biYPelsPerMeter members of the DIB structure of the image.
To compute the image height to be scaled proportionately to the image width, the new image width is divided by the original image width and multiplied by the image height. For example, if the current image is 300 x 600 pixels and you want to stretch it to 600 pixels wide 600 / 300 = 2 and 2 x 600 = 1200 pixels for the new image height.

Technical Support Team