DIB and BITMAP files can be saved to the disk as one of many file formats, including tif, bitmap, gif, jpg, pcx, etc. If the file format is not a multipage format and the file specified already exists, the saving procedure overwrites the image. If you choose a multipage file format (for example tif) and the file already exists, you can append the image to the existing file. Using this method, you can easily generate multipage images. There are specific saving functions for each supported image formats, and there is also a general saving function: SaveDIBInImageFormatExt.
[C++]
#include “BiTiff.h”
/* Save a DIB to a TIFF file */
BOOL bRet;
/* 1. parameter: Path and name of the file to save
2. parameter: Handle of the DIB to save
3. parameter: Compression of the image
4. parameter: Bit order (1 – normal 2 - reverse)
bRet = SaveDIBInTiffFileExt(“C:\\Images\\Test.tif”, hDib,
TCOMP_NOCOMP, FALSE, NORM_BIT_ORDER);
if (!bRet)
{
// Error
}
[VB]
‘ Save a DIB to a TIFF file
Dim bRet as Boolean
Dim BITiffobj As Object
Set BITiffobj = CreateObject("BITIFF.BITiffCtrl.1")
‘ 1. parameter: Path and name of the file to save
‘ 2. parameter: Handle of the DIB to save
‘ 3. parameter: Compression of the image
‘ 4. parameter: Display information dialog before saving
‘ the image
bRet = BITiffobj.SaveDIBInTiffFormat(“C:\Images\Test.tif”,
hDib, tifcmNoComp, True)
Set BITiffobj = Nothing
If bRet = false then
‘ Error
End If
[C#]
/* Save a DIB to a TIFF file */
bool bRet;
/* 1. parameter: Path and name of the file to save
2. parameter: Handle of the DIB to save
3. parameter: Compression of the image
4. parameter: Display information dialog before saving
the image */
bRet = BiTIFF.SaveDIBInTiffFormat(“C:\Images\Test.tif”,
hDib,BITIFFLib.enumCompressionTypes.TCOMP_NOCOMP,
True);
if (!bRet)
{
// Error
}