Loading dynamic bitmaps in FastReport

guzialguzial Poland
edited 8:15PM in FastReport 2.xx VCL
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

Comments

  • edited 8:15PM
    Firstly, identify if the problem is with a jpeg or bitmap...

    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).
  • guzialguzial Poland
    edited 8:15PM
    still the same AV in that same place
    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

  • guzialguzial Poland
    edited 8:15PM
    i have found solution

    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
  • gordkgordk St.Catherines On. Canada.
    edited 8:15PM
    modify your code a little
    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 ;)
  • guzialguzial Poland
    edited 8:15PM
    thank you - it's working ;)

    regards

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.