gflLibrary

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: helmut, XnTriq, xnview

Post Reply
dada
Posts: 3
Joined: Wed Apr 12, 2006 8:15 am
Location: Cracow

gflLibrary

Post by dada »

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
MaierMan
Posts: 78
Joined: Wed Aug 04, 2004 8:32 pm
Contact:

Re: gflLibrary

Post by MaierMan »

dada 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
Gimme some actual code ;)
(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 ); 
Hence it should be used like this:

Code: Select all

GFL_BITMAP *bmp, *cpy;
// do init stuff
gflLoad*(..., &bmp, ...);

gflResize(bmp, &cpy, w, h, m, f);
"cpy" does not have to be initialized or something. In fact it should not be initialized (execpt for cpy=NULL; )
You might want to gflFreeBitmap() first, in case you already loaded an image there.
dada
Posts: 3
Joined: Wed Apr 12, 2006 8:15 am
Location: Cracow

gflLibrary

Post by dada »

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.
MaierMan
Posts: 78
Joined: Wed Aug 04, 2004 8:32 pm
Contact:

Post by MaierMan »

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.

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); 
Actually the first way is simply shortcut for the latter. ;)
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);
	}
	...
}
Post Reply