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

}

 

[VB]

 

‘Change the DPI of an image

 

Dim bResult As Boolean

Dim BIDibObj As Object

Dim lNewDPI As Long

 

Set BIDibObj = CreateObject("BIDIB.BIDIBCtrl.1")

 

‘ 1. parameter: Handle of the DIB to change

‘ 2. parameter: New value of horizontal DPI

 

lNewDPI = 300

 

bResult = BIDibObj.SetDIBHorizontalDPI(hDib, lNewDPI)

 

If Not bResult Then

            ‘ Error

End If

 

‘ 1. parameter: Handle of the DIB to change

‘ 2. parameter: New value of vertical DPI

 

bResult = BIDibObj.SetDIBVerticalDPI(hDib, lNewDPI)

 

If Not bResult Then

            ‘ Error

End If

 

Set BIDibObj = Nothing

 

[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

}