-2

I found the code to do the following on this site, so thanks However the line "logo.Bitmap.LoadFromStream( MyRs);"

Access Violation - some kind of memory error I assume.

I used Project | Resources and Images ... to add the Jpeg

Is this a problem with the resource not being linked in, or rather my code?

Thanks :)

uses
  Classes, FMX.Graphics, FMX.Objects;

procedure MyProvedure();
var
     logo  : TImage;
     MyRS  : TResourceStream;
begin
  MyRS := TResourceStream.Create( HInstance, 'logo_1', RT_RCDATA );
  try
      logo.Bitmap.LoadFromStream( MyRs);
  finally
    MyRS.Free;
  end;
end;
Ari0nhh
  • 5,720
  • 3
  • 28
  • 33
Trevor
  • 1
  • 2
    Ask yourself what the lifetime of `logo` is? – David Heffernan Feb 03 '17 at 10:53
  • This procedure prints out a PDF with logo (the bitmap) - so the lifetime is ok - so long as it is first created!! (as Ari0nah states) - I then free it in the finally block. Thanks. – Trevor Apr 20 '17 at 15:56

1 Answers1

3

You have to create image before using it:

logo := TImage.Create(nil);
Ari0nhh
  • 5,720
  • 3
  • 28
  • 33