Converting Images from One File Format to Another

 

If you have to change the image file format of a file do the following:

  1. Load the image into a DIB (for example TIF)

  2. Save the DIB into the desired image format (for example JPG)

 

You can convert a DIB to Bitmap or a Bitmap to DIB with ConvertDIBToBitmap and ConvertBitmapToDIB. These functions are in the BiDIB DLL and OCX.

 

[C++]

 

/* Convert a DIB to a Bitmap*/

 

#include “BiDIB.h”

 

HBITMAP hBitmap;

 

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

 

hBitmap  = ConvertDIBToBitmap(hDib);

if (!hBitmap)

{

            // Error

}

 

[VB]

 

‘ Convert a DIB to a Bitmap

 

Dim hBitmap as Long

Dim BiDIBobj as Object

 

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

 

‘ 1. parameter: Handle of the DIB to convert

 

hBitmap = BiDIBobj. ConvertDIBToBitmap(hDib)

Set BiDIBobj = Nothing

 

If hBitmap = 0 Then

            ‘ Error

End If

 

[C#]

 

/* Convert a DIB to a Bitmap*/

 

int hBitmap;

 

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

 

hBitmap = BiDIB.ConvertDIBToBitmap(hDib);

if (hBitmap == 0)

{

            // Error

}