Store image(jpg) in a variable - Delphi

Asked

Viewed 550 times

0

I have a question about storing an image in a variable in Delphi. I’m using a function that saves as an image a signature collected in a digital signature collector (Step Over - naturaSign). However, this function only saves the image in a directory of my machine. I would like to know how to go to the directory path, take this image and finally store it in a variable. Thanks for your answers.

1 answer

0


The class TPicture has the procedure LoadFromFile to load an image, to use it would be more or less like this:

function CarregarImagem(caminhoImagem: String): TPicture;
var
  picture: TPicture;
begin
  picture := TPicture.Create();
  picture.LoadFromFile(caminhoImagem);
  Result := picture;
end;

To use the method just pass where the image is located:

var
  picture: TPicture;
begin
  picture := CarregarImagem('C:\teste.jpg');
end;

The class TPicture is located in Unit Graphics

  • Thank you very much my friend. It helped a lot!

  • TPicture.Create;

  • 1

    "Tgraphic" class also has "Loadfromfile()" procedure not function

  • @Sami, thank you for correcting me on the appointment issue. On the question of (), I like to use them to make it clear that it is a procedure, there is some kind of problem using this way?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.