Page 1 of 1
gflLoadBitmapFromHandle with Delphi
Posted: Mon Feb 14, 2005 12:03 am
by Philips10
Hi Pierre
Could you please give us Delphi-programmers a few lines of code that shows us how to use gflLoadBitmapFromHandle
I got
Code: Select all
ms := tmmorystream.creat
try
........
image1.picture.bitmap.savetostream(ms);
e := gflLoadBitmapFromHandle( ?? , gfl_bmp, lp, fInfo);
.........
finally
ms.free;
end;
If this is right so far, what to add for the two questionmarks ??
If not at all, please a few lines that shows the use of gflLoadBitmapFromHandle
Thanks and kind Regards
Jansen
Re: gflLoadBitmapFromHandle with Delphi
Posted: Thu Feb 17, 2005 2:03 pm
by xnview
Philips10 wrote:Could you please give us Delphi-programmers a few lines of code that shows us how to use gflLoadBitmapFromHandle
I got
Code: Select all
ms := tmmorystream.creat
try
........
image1.picture.bitmap.savetostream(ms);
e := gflLoadBitmapFromHandle( ?? , gfl_bmp, lp, fInfo);
.........
finally
ms.free;
end;
If this is right so far, what to add for the two questionmarks ??
If not at all, please a few lines that shows the use of gflLoadBitmapFromHandle
I don't know very well Delphi, perhaps someone who knows Delphi & C/C++ can help...
Re: gflLoadBitmapFromHandle with Delphi
Posted: Fri Feb 18, 2005 2:56 pm
by Andreas
Here is a small example in Borland C++.
A conversion to Delphi should be easy.
Code: Select all
//*********************
// CALLBACKS
//*********************
//---------------------------------------------------------------------------
GFL_UINT32 GFLAPI myReadFunction(GFL_HANDLE handle, void *buffer,
GFL_UINT32 size)
{
int ret = 0;
TStream *s = (TStream *)handle;
ret = s->Read(buffer, size);
return ret;
}
//---------------------------------------------------------------------------
GFL_UINT32 GFLAPI myTellFunction(GFL_HANDLE handle)
{
TStream *s = (TStream *)handle;
return s->Position;
}
//---------------------------------------------------------------------------
GFL_UINT32 GFLAPI mySeekFunction(GFL_HANDLE handle, GFL_INT32 offset,
GFL_INT32 origin)
{
Word soOrigin = 0;
TStream *s = (TStream *)handle;
switch(origin)
{
case SEEK_END:
soOrigin = soFromEnd;
break;
case SEEK_CUR:
soOrigin = soFromCurrent;
break;
case SEEK_SET:
default:
soOrigin = soFromBeginning;
break;
}
s->Seek(offset, soOrigin);
return s->Position;
}
//---------------------------------------------------------------------------
//*******************
// TestFunc
//*******************
void __fastcall TForm1::Testfunc()
{
GFL_LOAD_PARAMS lp;
GFL_FILE_INFORMATION fi;
GFL_BITMAP *gflbmp;
GFL_ERROR error;
TMemoryStream *ms = new TMemoryStream();
........
Image1->Picture->Bitmap->SaveToStream(ms);
gflGetDefaultLoadParams(&lp);
lp.ColorModel = GFL_BGR;
lp.LinePadding = 4;
lp.Callbacks.Read = myReadFunction;
lp.Callbacks.Tell = myTellFunction;
lp.Callbacks.Seek = mySeekFunction;
error = gflLoadBitmapFromHandle((GFL_HANDLE)ms, &gflbmp, &lp, &fi);
........
gflFreeBitmap(gflbmp);
delete ms;
}
Andreas