The Jpeg was grayscale 1280x1280 and I try to load it as 32bit rgb
The code I use to read it is:
Code: Select all
int GetImageInfo(char *fn, DWORD *dw, DWORD *dh, DWORD *bits, DWORD *ColorModel)
{
GFL_FILE_INFORMATION info;
bool ret=gflGetFileInformation(fn,-1,&info)==GFL_NO_ERROR;
*dw=info .Width;
*dh=info.Height;
*bits=info.BitsPerComponent*info.ComponentsPerPixel;
*ColorModel=info.ColorModel;
gflFreeFileInformation(&info);
return ret ? 1 : 0;
}
GFL_BITMAP *MyLoadImage(const char *filename)
{
GFL_LOAD_PARAMS load_params;
GFL_BITMAP *Bmp=NULL;
gflGetDefaultLoadParams(&load_params);
load_params.Flags |= GFL_LOAD_FORCE_COLOR_MODEL;// | GFL_LOAD_SKIP_ALPHA;
load_params.Origin = GFL_BOTTOM_LEFT;
DWORD tmp,bits,color;
if(GetImageInfo((char *)filename,&tmp,&tmp,&bits,&color))
if(bits=8 && color==GFL_CM_RGB)
load_params.ColorModel = GFL_ABGR;
else
load_params.ColorModel = GFL_BGRA;
load_params.LinePadding = 4;
load_params.FormatIndex=-1;
if(gflLoadBitmap(filename, &Bmp, &load_params, NULL))
MessageBox(NULL, "Error loading file!", NULL, MB_OK);
if(load_params.ColorModel == GFL_ABGR)
A2RGB((DWORD *)Bmp->Data,Bmp->Width,Bmp->Height,Bmp->BytesPerLine);
return Bmp;
}
GFL_BGRA returns a black image (1st bug?) so
I decided to use a different order of components (GFL_ABGR) that looked working, but I had to use an hack (bits=8 && color==GFL_CM_RGB) to understand if the picture is Grayscale and I'm quite sure it'll lead to mismatches, this is due to the fact that info.ColorModel returns color==GFL_CM_RGB (=0) in place of color==GFL_CM_GRAY (2nd bug?).
What's wrong?
Best regards.
P.S.
I almost forgot:
I can retrieve how many pictures a file contains but how can I load frames (eg: into an animated gif) and how can I retrieve its framerate?
Thanks in advance.