Filetype functions

Subsections

FreeImage_GetFileType

FREE_IMAGE_FORMAT FreeImage_GetFileType(const char *filename, int size);

Investigates the bitmap data from the given bitmap and returns the FreeImage Format ID for it. FreeImage_GetFileType will read the first size bytes of the file but not more than 16. FreeImage_GetFileType will return one of the following values:

Type Bitmap
FIF_UNKNOWN Unidentified bitmap type
FIF_BMP Windows or OS/2 Bitmap
FIF_ICO Windows Icon
FIF_JPEG JPEG - JFIF Compliant
FIF_JNG JPEG Network Graphics
FIF_KOALA C64 Koala Graphics
FIF_LBM Deluxe Paint LBM
FIF_MNG Multiple Network Graphics
FIF_PBM Portable Bitmap
FIF_PCD Kodak PhotoCD
FIF_PCX Zsoft Paintbrush
FIF_PGM Portable Greymap
FIF_PNG Portable Network Graphics
FIF_PPM Portable Pixmap
FIF_RAS Sun Raster Image
FIF_TARGA Truevision Targa
FIF_TIFF Tagged Image File Format
FIF_WBMP Wireless Bitmap

FreeImage_GetFileTypeFromHandle

FREE_IMAGE_FORMAT FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size);

Investigates the bitmap data from the given bitmap and returns the FreeImage Format ID for it. Code example:

unsigned

_ReadProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle) {

return fread(buffer, s, c, (FILE *)handle);

}

unsigned

_WriteProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle){

return fwrite(buffer, s, c, (FILE *)handle);

}

int

_SeekProc(fi_handle handle, long offset, int origin) {

return fseek((FILE *)handle, offset, origin);

}

long

_TellProc(fi_handle handle) {

return ftell((FILE *)handle);

}

FreeImageIO io;

io.read_proc = _ReadProc;

io.write_proc = _WriteProc;

io.seek_proc = _SeekProc;

io.tell_proc = _TellProc;


FILE *file = fopen("test.bmp", "rb");

FREE_IMAGE_TYPE type;
type = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)file, 16);

FreeImage_GetFileTypeFromExt

FREE_IMAGE_FORMAT FreeImage_GetFileTypeFromExt(const char *ext);

This function is deprecated. FreeImage_GetFIFFromFilename has replaced its functionality.