FastReport LoadImageFromHbVar

Post Reply
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

FastReport LoadImageFromHbVar

Post 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
ShumingWang
Posts: 467
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China
Contact:

Re: FastReport LoadImageFromHbVar

Post 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
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: FastReport LoadImageFromHbVar

Post 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
User avatar
Enrico Maria Giordano
Posts: 8761
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: FastReport LoadImageFromHbVar

Post 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

Code: Select all | Expand

M -> myvar


EMG
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: FastReport LoadImageFromHbVar

Post 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
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: FastReport LoadImageFromHbVar

Post by Marcelo Via Giglio »

found! DibToStr( hDib )

thanks

Marcelo
User avatar
rhlawek
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: FastReport LoadImageFromHbVar

Post by rhlawek »

Marcelo,

Can you share the details regarding how you were able to load the bitmap from memory?

Regards,

Robb
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: FastReport LoadImageFromHbVar

Post 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
User avatar
rhlawek
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: FastReport LoadImageFromHbVar

Post 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
Post Reply