I'm writing application in C++Builder environment. Now I'm interesting of the one-color bitmaps. I created class with two gflBitmap objects - for example gflb1 and gflb2. When I tried to resize the first of them to the second with using of glfResize function, the address of the gflb2 is moved on 88 bytes. When I clone gflb1 to the gflb2 and after that resize gflb2 to the same bitmap (using parameter NULL in please of destination bitmap) everything is Ok, but it is more time consuming. Please help me.
Best Wishes with the Easter Eve for authors and every member of this forum
Dada
gflLibrary
Moderators: helmut, XnTriq, xnview
Re: gflLibrary
Gimme some actual codedada wrote:I'm writing application in C++Builder environment. Now I'm interesting of the one-color bitmaps. I created class with two gflBitmap objects - for example gflb1 and gflb2. When I tried to resize the first of them to the second with using of glfResize function, the address of the gflb2 is moved on 88 bytes. When I clone gflb1 to the gflb2 and after that resize gflb2 to the same bitmap (using parameter NULL in please of destination bitmap) everything is Ok, but it is more time consuming. Please help me.
Best Wishes with the Easter Eve for authors and every member of this forum
Dada

(Using BCB6 quite regular myself, I might be able to help debug the stuff.)
Some general hints:
gflResize is declared like this
Code: Select all
extern GFLEXTERN GFL_ERROR GFLAPI gflResize( GFL_BITMAP *src, GFL_BITMAP **dst, GFL_INT32 width, GFL_INT32 height, GFL_UINT32 method, GFL_UINT32 flags );
Code: Select all
GFL_BITMAP *bmp, *cpy;
// do init stuff
gflLoad*(..., &bmp, ...);
gflResize(bmp, &cpy, w, h, m, f);
You might want to gflFreeBitmap() first, in case you already loaded an image there.
gflLibrary
Thanks for Your answer. I do everything like You shoved me but it is not working. I discovered the same problem with another gflLibrary functions except gflResize. For example this code:
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
gflCrop(bmp, &cpy, w, h, m, f);
shifts cpy address on 88 bytes but code
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
cpy = glfCloneBitmap( bmp )
gflCrop(cpy, NULL, w, h, m, f);
does not shift address of cpy
Remember tha it must be moochromatic image.
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
gflCrop(bmp, &cpy, w, h, m, f);
shifts cpy address on 88 bytes but code
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
cpy = glfCloneBitmap( bmp )
gflCrop(cpy, NULL, w, h, m, f);
does not shift address of cpy
Remember tha it must be moochromatic image.
Think I finally got what you mean.
There is a reason that the second parameter takes a pointer-to-pointer argument: It reassigns the "pointed pointer".
It doesn't care if cpy already has a value assigned.
It will simply override the address pointed by copy.
This per design (and perfectly valid).
Your gflCloneBitmap snippet actually reassigns the pointer too.
Actually the first way is simply shortcut for the latter. 
I assume s.th. like this is done within those functions
There is a reason that the second parameter takes a pointer-to-pointer argument: It reassigns the "pointed pointer".
It doesn't care if cpy already has a value assigned.
It will simply override the address pointed by copy.
This per design (and perfectly valid).
Your gflCloneBitmap snippet actually reassigns the pointer too.
Code: Select all
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
gflCrop(bmp, &cpy, w, h, m, f); /* reassigns cpy */
...
GFL_BITMAP *bmp, *cpy;
gflLoad*(..., &bmp, ...);
cpy = glfCloneBitmap( bmp ); /* reassigns cpy */
gflCrop(cpy, NULL, w, h, m, f);

I assume s.th. like this is done within those functions
Code: Select all
gflDoSomething(GFL_BITMAP *src, GFL_BITMAP **dst)
{
...
if (dst)
{
src = *dst = gflCloneBitmap(src);
}
...
}