Loading dynamic bitmaps in FastReport
guzial
Poland
I have problem with bitmaps...
I have to load variable from INI to Report. One of varaible is name of bitmap file and that file i have to load to frPictureView.
i try
var PV: TfrPictureView;
begin
guzial_ini := TINIFile.Create('../plik2.ini');
frReport4.LoadFromFile('test4.frf');
PV := TfrPictureView.Create;
PV :=(frReport1.FindObject('Picture1') as TfrPictureView);
PV.Picture.LoadFromFile('c:\a.jpg'); <- exeption there is something wrong
frReport4.PrepareReport;
frReport4.ShowReport;
end;
but i dont know if it is right if yes where is error(??)
who can help me??
ps sorry for my english
I have to load variable from INI to Report. One of varaible is name of bitmap file and that file i have to load to frPictureView.
i try
var PV: TfrPictureView;
begin
guzial_ini := TINIFile.Create('../plik2.ini');
frReport4.LoadFromFile('test4.frf');
PV := TfrPictureView.Create;
PV :=(frReport1.FindObject('Picture1') as TfrPictureView);
PV.Picture.LoadFromFile('c:\a.jpg'); <- exeption there is something wrong
frReport4.PrepareReport;
frReport4.ShowReport;
end;
but i dont know if it is right if yes where is error(??)
who can help me??
ps sorry for my english
Comments
try loading a bitmap in - if you don't get an AV, you need to ensure you have the JPEG define in fr.inc (also include the jpeg unit in your uses clause).
you could also try creating a TJPEGFile, using LoadFromFile with this and then PV.picture.assign(ojpegfile).
even when i want to load bmp is the same - but i have to load jpg
but i would be grateful if i could load bmp than i try to load jpg
check this code - probably there is something wrong?? i dont know because it's look like it was problem with PV object.. i realy don't know
i add script to Picture1 (TfrPictureView object) :
begin
Picture1.LoadFromFile(filename)
end
and it doesn't matter if it is bmp or jpg
but i would like to know how to do it in delphi
from this
var PV: TfrPictureView;
begin
guzial_ini := TINIFile.Create('../plik2.ini');
frReport4.LoadFromFile('test4.frf');
PV := TfrPictureView.Create;
PV :=(frReport1.FindObject('Picture1') as TfrPictureView);
PV.Picture.LoadFromFile('c:\a.jpg'); <- exeption there is something wrong
frReport4.PrepareReport;
frReport4.ShowReport;
end;
to this
var V: TfrView;
begin
guzial_ini := TINIFile.Create('../plik2.ini');
frReport4.LoadFromFile('test4.frf');
V :=(frReport1.FindObject('Picture1');
tfrpictureview(V).Picture.LoadFromFile('c:\a.jpg');
frReport4.PrepareReport;// don't need if calling showreport or if you call prepare then use showpreparedreport instead of ShowReport;
end;
tip
turn on auto code completion and when writing code like this
tfrpictureview(V).Picture.LoadFromFile('c:\a.jpg');
when you type the period wait and you will find all the classes properties and their types available to you at that point.
regards
regards