FastReport LoadImageFromHbVar

FastReport LoadImageFromHbVar

Postby Marcelo Via Giglio » Wed Apr 16, 2014 3:04 pm

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
Marcelo Via Giglio
 
Posts: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: FastReport LoadImageFromHbVar

Postby ShumingWang » Thu Apr 17, 2014 4:24 am

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

Re: FastReport LoadImageFromHbVar

Postby Marcelo Via Giglio » Thu Apr 17, 2014 3:01 pm

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
Marcelo Via Giglio
 
Posts: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: FastReport LoadImageFromHbVar

Postby Enrico Maria Giordano » Thu Apr 17, 2014 3:30 pm

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 view  RUN
M -> myvar


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FastReport LoadImageFromHbVar

Postby Marcelo Via Giglio » Thu Apr 17, 2014 7:50 pm

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: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: FastReport LoadImageFromHbVar

Postby Marcelo Via Giglio » Fri Apr 18, 2014 2:41 am

found! DibToStr( hDib )

thanks

Marcelo
Marcelo Via Giglio
 
Posts: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: FastReport LoadImageFromHbVar

Postby rhlawek » Tue Jun 10, 2014 8:52 pm

Marcelo,

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

Regards,

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

Re: FastReport LoadImageFromHbVar

Postby Marcelo Via Giglio » Tue Jun 10, 2014 9:32 pm

Robb,

the question is not clear for me but I can public some code

Code: Select all  Expand view  RUN

   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
Marcelo Via Giglio
 
Posts: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: FastReport LoadImageFromHbVar

Postby rhlawek » Tue Jun 10, 2014 10:11 pm

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests