Page 1 of 1
FastReport LoadImageFromHbVar
Posted: Wed Apr 16, 2014 3:04 pm
by Marcelo Via Giglio
Hello,
I am trying to print a image in FR, I want to use LoadImageFromHbVar because I need to generate the image only for the report.
I found a topic about it but for me don't work, some body work with this function?
regards
Marcelo
Re: FastReport LoadImageFromHbVar
Posted: Thu Apr 17, 2014 4:24 am
by ShumingWang
1. Static
Add picture object-- close the "picture" windows--left tribution table--file link--- d:\myfold\aaaa.jpg --OK
2. Dynamic
2.1). Add picture object-- close the "picture" windows--left tribution table--event Picture1OnBeforePrint
2.2). code:
procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
callhbfunc('fr3img',['.\sub\'+vartostr(<masterdata."imgid">)+'.jpg']) ; // this selft defined prg function to load current row jpg into private 'myvar'
LoadImageFromHbVar(Picture1,'fr3img');
end;
begin
end.
// " picture1" is the name of the picture object, can be edited in the left tribution table .
2.3) prg :
private fr3img
FrPrn := frReportManager():new()
2.4 prg:
FUNCTION fr3img(file1)
fr3img:=nil
fr3img:=memoread(file1)
sysrefresh()
return
Re: FastReport LoadImageFromHbVar
Posted: Thu Apr 17, 2014 3:01 pm
by Marcelo Via Giglio
ShumingWang,
thanks very much for your response, I found my problem, we MUST to define the variable like a PRIVATE (don't work with other definition), then we need to relax the xHarbour compile switch
because with private variables I get error message "Ambiguous reference" I don't know why?
regards
Marcelo
Re: FastReport LoadImageFromHbVar
Posted: Thu Apr 17, 2014 3:30 pm
by Enrico Maria Giordano
Marcelo,
Marcelo Via Giglio wrote:ShumingWang,
thanks very much for your response, I found my problem, we MUST to define the variable like a PRIVATE (don't work with other definition), then we need to relax the xHarbour compile switch
because with private variables I get error message "Ambiguous reference" I don't know why?
regards
Marcelo
Use
EMG
Re: FastReport LoadImageFromHbVar
Posted: Thu Apr 17, 2014 7:50 pm
by Marcelo Via Giglio
Thanks Enrico,
I didn't use PRIVATE variables since clipper.
Other question how can I get the same result than MEMOREAD("bmpfile.bmp") using a bmp object. I have a bmp in memory (generated), how can I convert this BMP to use like MEMOREAD whiout pass it to a disk file.
Regards
Marcelo
Re: FastReport LoadImageFromHbVar
Posted: Fri Apr 18, 2014 2:41 am
by Marcelo Via Giglio
found! DibToStr( hDib )
thanks
Marcelo
Re: FastReport LoadImageFromHbVar
Posted: Tue Jun 10, 2014 8:52 pm
by rhlawek
Marcelo,
Can you share the details regarding how you were able to load the bitmap from memory?
Regards,
Robb
Re: FastReport LoadImageFromHbVar
Posted: Tue Jun 10, 2014 9:32 pm
by Marcelo Via Giglio
Robb,
the question is not clear for me but I can public some code
Code: Select all | Expand
oBmp:= TBitmap():Define()
oBmp:hBitMap := BuildCode( CODEBAR_QR, "QR", HB_ZEBRA_FLAG_QR_LEVEL_MASK ) //create bitmap in memory
hDib := DibFromBitmap( oBmp:hBitMap ) // read dib from bitmap
DibToStr( hDib ) // convert dib to string
GloBalFree( hDib )
regards
Marcelo
Re: FastReport LoadImageFromHbVar
Posted: Tue Jun 10, 2014 10:11 pm
by rhlawek
Thank you, that was quick.
I finally found what I need, or at least what I can use. There is a TBitmap() method named LoadFromString() that does the trick. Finally found it in the source code, it doesn't appear to be documented otherwise.
Thank you so much for the reply.
Robb