Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

RB 10.04 JPEG Access Violation

edited November 2006 in General
Why does the following give me an access violation?

I have the ppJPEG unit included in my uses statement.

procedure TAdvertisingForm.rImage1Print(Sender: TObject);
begin
TppImage(Sender).Picture.LoadFromFile('c:\Test.jpg');
end;

Have also tried rImage.Picture.LoadFromFile('c:\Test.jpg');

Thanks,

Ken

Comments

  • edited November 2006
    Hi Ken,

    In my testing with your exact code below, I was able to successfully load a
    Jpeg image into a TppImage object. Are you certain that Test.jpg is a valid
    Jpeg file?

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2006
    Nico,

    Yes I am as I am already loading it into a TImage in my project.

    Ken

  • edited November 2006
    Nico,

    Sorry. I had left a line of code in that shouldn't have been there.
    LoadFromFile works fine.

    What I am actually trying to do is the following and I get a "Bitmap is not
    valid" error when it runs.

    if not qAdvert.FieldByName('Image1').IsNull then
    TppImage(Sender).Picture.Assign(qAdvert.FieldByName('Image1'));

    qAdvert is a nexes Query. I need to load it like this as I eventually need
    to do some manipulation of the image prior to loading it into the TppImage.

    Ken



  • edited November 2006
    Hi Ken,

    I believe the code you have below needs to be fired before the
    TppImage.OnPrint event in order to function correctly. Also, be sure you
    use the pipeline routines to get access to the field values manually. Try
    something like the following...

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    begin
    ppImage1.Picture.Assign(ppReport1.DataPipeline.GetFieldAsPicture('Image'));
    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.