I'm very pleased with all the power and functionnalities of FreeImage, but unfortunately, I encounter a small problem.
I'm actually developing an embedded DLL in Visual C++ and I need to reduce the size of FreeImage, which is used as a static library. The size of my DLL is only 200kb but raise up to 1 mega when linking to FreeImage.
Then I decided I had no use of most of the image format and I removed most of them from the source (pluginxxx.cpp etc.). Then I reduce the total size of my plugin to a small 400kb.
And my problem occurs: my dll works fine, EXCEPT when loading gif file. Of course I didnt remove the gif plugin from the freeimage code, but it appears that if I remove any plugin not related to gif, the gif functions crash.
What I change is only the FreeImage_Initialise() function. Example: if I remove one of the following lines:
This problem is linked to the fact that the FREE_IMAGE_FORMAT enum use the same numbering as the order used by the AddNode functions.
As a general rule, avoid the use of the FREE_IMAGE_FORMAT constants when using FreeImage_Load, use instead FreeImage_GetFileType or FreeImage_GetFIFFromFilename. This way, you can be sure that you will always have a valid fif.
Herve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I'm very pleased with all the power and functionnalities of FreeImage, but unfortunately, I encounter a small problem.
I'm actually developing an embedded DLL in Visual C++ and I need to reduce the size of FreeImage, which is used as a static library. The size of my DLL is only 200kb but raise up to 1 mega when linking to FreeImage.
Then I decided I had no use of most of the image format and I removed most of them from the source (pluginxxx.cpp etc.). Then I reduce the total size of my plugin to a small 400kb.
And my problem occurs: my dll works fine, EXCEPT when loading gif file. Of course I didnt remove the gif plugin from the freeimage code, but it appears that if I remove any plugin not related to gif, the gif functions crash.
What I change is only the FreeImage_Initialise() function. Example: if I remove one of the following lines:
if (s_plugins) {
s_plugins->AddNode(InitBMP);
s_plugins->AddNode(InitICO);
s_plugins->AddNode(InitJPEG);
//s_plugins->AddNode(InitMNG, NULL, "JNG", "JPEG Network Graphics", "jng", "");
s_plugins->AddNode(InitKOALA);
s_plugins->AddNode(InitIFF);
s_plugins->AddNode(InitMNG);
s_plugins->AddNode(InitPNM, NULL, "PBM", "Portable Bitmap (ASCII)", "pbm", "^P1");
s_plugins->AddNode(InitPNM, NULL, "PBMRAW", "Portable Bitmap (RAW)", "pbm", "^P4");
s_plugins->AddNode(InitPCD);
s_plugins->AddNode(InitPCX);
s_plugins->AddNode(InitPNM, NULL, "PGM", "Portable Greymap (ASCII)", "pgm", "^P2");
s_plugins->AddNode(InitPNM, NULL, "PGMRAW", "Portable Greymap (RAW)", "pgm", "^P5");
s_plugins->AddNode(InitPNG);
s_plugins->AddNode(InitPNM, NULL, "PPM", "Portable Pixelmap (ASCII)", "ppm", "^P3");
s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6");
s_plugins->AddNode(InitRAS);
s_plugins->AddNode(InitTARGA);
s_plugins->AddNode(InitTIFF);
s_plugins->AddNode(InitWBMP);
s_plugins->AddNode(InitPSD);
s_plugins->AddNode(InitCUT);
s_plugins->AddNode(InitXBM);
s_plugins->AddNode(InitXPM);
s_plugins->AddNode(InitDDS);
s_plugins->AddNode(InitGIF);
//....
Removing any of this plugin (for example s_plugins->AddNode(InitMNG...) will crash GIF loading.
Any idea of what's wrong ?
This problem is linked to the fact that the FREE_IMAGE_FORMAT enum use the same numbering as the order used by the AddNode functions.
As a general rule, avoid the use of the FREE_IMAGE_FORMAT constants when using FreeImage_Load, use instead FreeImage_GetFileType or FreeImage_GetFIFFromFilename. This way, you can be sure that you will always have a valid fif.
Herve
no idea about this issue ?