ImageGear for C and C++ on Windows v19.4 - Updated
Convert Image Format
User Guide > How to Work with... > Common Operations > Compressing and Converting Images > Convert Image Format

Converting a file from one file format to another is simply a matter of loading a file from disk using IG_load_file() or other load function, and then saving it with a new format type. However, make sure that the bit depth of the original file can be supported by the new format type - see Format Bit Depths for a complete delineation of the bit depths supported by each format.

The following example demonstrates converting a Windows Bitmap file (BMP) to a TIFF file:

 
Copy Code
HIGEAR      hIGear;        /* HIGEAR handle returned        */
AT_ERRCOUNT nErrcount;     /* # of errors on stack          */
AT_LMODE    lFormatType;   /* format to save to             */
/* Set name of BMP file to load and format to save to       */
lFormatType = IG_SAVE_TIF_UNCOMP;
/* Load picture.bmp, obtaining ImageGear handle of image     */
nErrcount = IG_load_file("picture.bmp", &hIGear);
if (nErrcount == 0 )          /* If successful:              */
{
    /* save image as a TIFF file:                            */
    nErrcount = IG_save_file(hIGear, "picture.tif", lFormatType );
}
If the file named "picture.tif" already exists, the image will be appended to "picture.tif" because TIFF supports multiple images in a single file.

For more information on the ImageGear IG_save_...() functions, see Save Functions.

To save an image using ImageGear, it must have a HIGEAR handle. If your image is in DIB format, use: IG_image_DIB_import() or IG_image_create_DIB_ex() to assign it a HIGEAR handle. If the image is a DDB, use IG_dspl_DDB_import().