On Fri, Jul 26, 2019 at 4:44 PM "Hervé Drolon" drolon@users.sourceforge.net wrote: see https://stackoverflow.com/questions/57117923/strange-segfault-when-calling-freeimage-getpixelcolor Yeah, that's my post there :) Never received any replies though. see https://sourceforge.net/p/freeimage/bugs/295/ Thank you very much for your tips which you listed here : https://sourceforge.net/p/freeimage/bugs/295/#c589 :) Problems for FreeImage_Load() and buffer overflows Sent from sourceforge.net because you...
FreeImage doesn't complain about not being able to load the TIFF file. Here's the code that loads said file : int main(int argc, char **argv) { if (argc <= 1) { //fprintf(stderr, "You must specify a PNG input file...\n"); fprintf(stderr, "You must specify an input file...\n"); //printf("You must specify a PNG input file...\n"); return(1); } FreeImage_Initialise(0); FreeImage_SetOutputMessage(FreeImageErrorHandler); FIBITMAP *image_data; //FIBITMAP *image_data = FreeImage_Load(FIF_PNG, "lena.png",...
Well, the problem was my misunderstanding the FreeImage_GetPixelColor() function :) See the following discussion on the bugs page for the solution : https://sourceforge.net/p/freeimage/bugs/295/ . jdb2
Well, I can't seem to figure out how to mark this ticket as closed / solved, so an admin will have to do it, unless I'm missing something obvious, which I probably am :). jdb2
It looks like you've found the source of the problem! :D Thanks so much! I guess I wasn't fully understanding the semantics of the RGBQUAD pointer passed to FreeImage_GetPixelColor(). My code now doesn't segfault in the FreeImage library anymore thanks to your suggestion :D Thanks a lot! :D I'll mark this "bug "as solved / closed :) Regards, jdb2
FreeImage_GetPIxelColor() takes an RGBQUAD pointer, so the code : //RGBQUAD *rgb1; RGBQUAD rgb1; ... //if(!FreeImage_GetPixelColor(image, (unsigned) x, (unsigned) y, rgb1)) { if(!FreeImage_GetPixelColor(image, (unsigned) x, (unsigned) y, &rgb1)) { ... } generates the following errors : ccc-common.c: In function ‘getPixels’: ccc-common.c:125:67: warning: passing argument 4 of ‘FreeImage_GetPixelColor’ from incompatible pointer type [-Wincompatible-pointer-types] if(!FreeImage_GetPixelColor(image,...
FreeImage_GetPIxelColor() takes an RGBQUAD pointer, so the code : //RGBQUAD *rgb1; RGBQUAD rgb1; ... //if(!FreeImage_GetPixelColor(image, (unsigned) x, (unsigned) y, rgb1)) { if(!FreeImage_GetPixelColor(image, (unsigned) x, (unsigned) y, &rgb1)) { ... } generates the following errors : ccc-common.c: In function ‘getPixels’: ccc-common.c:125:67: warning: passing argument 4 of ‘FreeImage_GetPixelColor’ from incompatible pointer type [-Wincompatible-pointer-types] if(!FreeImage_GetPixelColor(image,...
Just to make things a little more clear, here is the path my code takes before calling FreeImage_GetPixelColor() at which point I receive a segfault from the FreeImage library : #include "ccc-common.h" int main(int argc, char **argv) { char *cpmsg = (char *) FreeImage_GetCopyrightMessage(); printf("( %s ) \n\n", cpmsg); if (argc <= 1) { fprintf(stderr, "You must specify an input file...\n"); return(1); } FreeImage_Initialise(0); FreeImage_SetOutputMessage(FreeImageErrorHandler); FIBITMAP *image_data;...