Change an Image DPI

 

Use SetDIBDPI function from BiDib DLL to change the horizontal and vertical DPI values of an image. Use SetDIBHorizontalDPI and SetDIBVerticalDPI methods from BiDib OCX to change DPI of an image.

 

[C++]

 

/* Change the DPI of an image */

 

#include “BiDib.h”

 

BOOL bResult;

UINT xDPI, yDPI;

 

/* 1. parameter: Handle of the DIB to change

   2. parameter: New value of horizontal DPI

   3. parameter: New value of vertical DPI */

 

xDPI = yDPI = 300;

 

bResult = SetDIBDPI(hDib, xDPI, yDPI);

 

if (!bResult)

{

            // Error

}

 

[C#]

 

/* Change the DPI of an image */

 

bool bResult;

int iNewDPI = 300;

 

/* 1. parameter: Handle of the DIB to change

   2. parameter: New value of horizontal DPI */

 

bResult = BiDib.SetDIBHorizontalDPI(hDib, iNewDPI);

 

if (!bResult)

{

            // Error

}

 

/* 1. parameter: Handle of the DIB to change

   2. parameter: New value of vertical DPI */

 

bResult = BiDib.SetDIBVerticalDPI(hDib, iNewDPI);

 

if (!bResult)

{

            // Error

}