Question about gflResizeCanvas / VB sample with Delphi

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

Moderators: helmut, XnTriq, xnview

Post Reply
klaus2

Question about gflResizeCanvas / VB sample with Delphi

Post by klaus2 »

Hi experts,

as i have resize speed problems with the Delphi's TImage, i tried to test with the gflResizeCanvas as used in the Visual Basic sample "Form 10".

First i needed to adapt the VB code (i can read it only, because i cannot make it run with VB5) to Delphi; centered along the VB functions (plus helpers)
extGetGflBitmapFromPtr and extShowBitmapOnDc
for to test if i can display my (good) gfl_bmp (PGFL_BITMAP) via those functions (based on a GFL_BITMAP resp. TGFL_BITMAP object) on an Delphi TImage.

I adapted those functions so far, but the result image resp. device context ... is simply white.
Is there anybody who can help to track this down resp. has a working adaption of "extShowBitmapOnDc" resp. gflResizeCanvas for Delphi?

More general, is this approach (by going the fast DIB-way [extShowBitmapOnDc uses StretchDIBits)) the recommed way to react on resize actions on the user interface? (does xnview itself do so?)

Many thanks and best regards,
klaus2
klaus2

Post by klaus2 »

I succeeded to adapt the VB functios extGetGflBitmapFromPtr and extShowBitmapOnDc
(From VB example gflResizeCanvas.frm) to Delphi, but i have 2 problems with it; see below.
Many thanks for any clues in advance!

If i can fix those problems, i expect that i can do a fast image resize reacting of user change of the window size, using gflResizeCanvas and modifying the DestRect of the StretchDIBits. Am i right?

Best Regards,
klaus2

Prob 1: the output image flipped vertically by 180 degrees (top is bottom and vice versa);
obviously dib-specific (built up upside down); possible solutions without loosing too much speed?
(btw the VB sample does _not_ show the image flipped)

Prob 2: access violation with gflMemoryFree in extGetGflBitmapFromPtr

Code: Select all

procedure extGetGflBitmapFromPtr(src: Pointer; var dest: TGFL_BITMAP);
var pdest: PGFL_BITMAP;
begin
    pdest :=  @dest;    // address of dest
    gflFreeBitmapData(pdest);
    CopyMemory(pdest, src, SizeOf(TGFL_BITMAP));
    gflMemoryFree(src);   // <--- Access violation here (on Delphi6/Win2K only, not with D4/Win98)
end;


The function is called like: extGetGflBitmapFromPtr(Pointer(pgfl_bmp), gfl_bmp);
where "src" resp. "pgfl_bmp" is defined as an instance variable of the Form as: pgfl_bmp: PGFL_BITMAP;
it's retrieved from the gflLoadBitmap.
klaus2

Post by klaus2 »

About the vertical flip of the DIB derived image, i can fix it with
"loadparams.Origin := GFL_BOTTOM_LEFT;" for the gflLoadBitmap,
but - ouch! - that's ugly because i need an original windows Bitmap object too
fron the gflLoadBitmap (as of Delphi sample code) .... and now, of course, that one would be flipped.
Some way around?
Post Reply