Page 1 of 1
GFL SDK v2.90 gflResize Error
Posted: Wed Oct 29, 2008 12:24 pm
by Zai++
This code worked successfully on 267 version, but it fails on 290:
Code: Select all
GFL_BITMAP* Dst=NULL;
//Src - pointer to existing bitmap
gflResize(Src, &Dst, SaveW, SaveH, .., ..);
Access violation in module LIBGFL290.DLL

Posted: Thu Oct 30, 2008 8:31 am
by dominique
If you didn't read the help or for other user with similar problem :
I use gflResize without problem. You should write NULL directly to resize in the Src bitmap (written in the help). Here, &Dst is not NULL, just the pointer Dst is NULL so the lib may try to do something with a nowhere pointer.
I made a similar mistake writing the same bitmap in Src and Dest.
Posted: Wed Nov 05, 2008 3:36 pm
by Zai++
>I made a similar mistake writing the same bitmap in Src and Dest.
It's not a mistake. In previous version when gflResize got a pointer to NULL in Dst parametr it created a new GFL_BITMAP object
and now it fails.
>You should write NULL directly to resize in the Src bitmap (written in the help).
I don't need to resize Src. I need to get a resized copy of Src in Dst.
PS. The resizing of Src (as you suggested) also fails!
Code: Select all
gflResize(Src, NULL, SaveWSync, SaveHSync, GFL_RESIZE_BILINEAR, 0);
Access violation in module LIBGFL290.DLL
Help!

Posted: Wed Nov 05, 2008 3:56 pm
by xnview
Zai++ wrote:
Code: Select all
gflResize(Src, NULL, SaveWSync, SaveHSync, GFL_RESIZE_BILINEAR, 0);
Access violation in module LIBGFL290.DLL
??? Your Src is a good bitmap?
Posted: Thu Nov 06, 2008 10:32 am
by dominique
I didn't realize you want to resize in an other Bitmap

I try this code without problem :
Code: Select all
gflLibraryInit();
AnsiString lFileIn = "TestResize.tif";
GFL_LOAD_PARAMS lLoadOption;
GFL_FILE_INFORMATION lDestImageInfo;
GFL_BITMAP* lSrcBitmap;
GFL_BITMAP* lDestBitmap;
gflGetDefaultLoadParams(&lLoadOption);
GFL_ERROR lError = gflLoadBitmap(lFileIn.c_str(), &lSrcBitmap, &lLoadOption, &lDestImageInfo);
if (lError != GFL_NO_ERROR)
ExitProcess(lError);
lDestBitmap = NULL;
lError = gflResize(lSrcBitmap, &lDestBitmap, lSrcBitmap->Width / 2, lSrcBitmap->Height / 2, GFL_RESIZE_BILINEAR, 0);
if (lError != GFL_NO_ERROR)
ExitProcess(lError);
gflFreeFileInformation(&lDestImageInfo);
gflFreeBitmap(lSrcBitmap);
gflFreeBitmap(lDestBitmap);
gflLibraryExit();
Perhaps you should check the error on the gflLoadBitmap.
Rgds
Posted: Thu Nov 06, 2008 2:28 pm
by Zai++
Thanks for your cooperation

The problem is solved! The description is below (if you are interested in)
gflResize works correct when the function uses GFL_BITMAPs with their own data, I mean, GFL_BITMAP::Data points to a memory created with gflAllockBitmap, gflLoadBitmap etc.
But I use GFL_BITMAP with alien data, that is GFL_BITMAP::Data points to a memory of WinAPI DIBSection. This allows me to load and save windows bitmaps. So I have a wrap class over the GFL_BITMAP. It fills GFL_BITMAP like this:
Code: Select all
G.Data=reinterpret_cast<GFL_UINT8>(const_cast<void>(Saveable->GetDataAddress()));
G.LinePadding=Saveable->AlignRow;
G.BytesPerLine=Saveable->VB;
switch(dpp)
{
case 32:
G.Type= GFL_BGRA;
G.ComponentsPerPixel=G.BytesPerPixel=4;
break;
case 24:
G.Type= GFL_BGR;
G.ComponentsPerPixel=G.BytesPerPixel=3;
break;
case 8:
G.Type= GFL_GREY;
G.ComponentsPerPixel=G.BytesPerPixel=1;
break;
...and so on
Previous versions of GFL had small error. I need to write
Code: Select all
G.LinePadding=G.BytesPerLine;
instead of
G.LinePadding=4;//real padding
Otherwise GFL failed (save, resize and others)
Now this error is fixed, but because of this old code with (G.LinePadding=G.BytesPerLine;) doesn't work correct and resize operation fails, while other (save for example) works correct!
I spent several hours to find it. So the solution is "G.LinePadding=4;"
PS. GFL help says:
Code: Select all
GFL_BITMAP::LinePadding Internal use, do not modify.
I'm laughing
PPS. sorry for taking your time
Posted: Thu Nov 06, 2008 2:59 pm
by dominique
But I use GFL_BITMAP with alien data, that is GFL_BITMAP::Data points to a memory of WinAPI DIBSection
I'm not shure but you have special functions to translate this kind of Bitmap. From the doc :
gflConvertBitmapIntoDIB
The gflConvertBitmapIntoDIB function converts a GFL_BITMAP in a Windows Device Independant Bitmap
and
gflConvertDIBIntoBitmap
The gflConvertDIBIntoBitmap function converts a Windows Device Independant Bitmap into GFL_BITMAP.
If the help says not to change a value I think it's better to do not. LinePadding should be calculated internally while building a specific bitmap with a given type and count of pixel. I imagine it's to have a specific BytesPerLine to faster pixel access or algorithm calculation.
So I use to make wrappers with other libs and I prefer to use libs to allocate bitmaps specifying size and pixels'type. And then you can copy from one buffer to an other using one index/pointer for each buffer. So libs can correclty managed memory and "protected" members

Posted: Fri Nov 07, 2008 12:09 pm
by Zai++
> you have special functions to translate this kind of Bitmap
translating needs much time and memory, especially with large images
I don't want to waste resources just copying megabytes
I prefer to use undocumented features and ..

.. am ready for future troubles