Canvas Draw Tbitmap Multiple Images

Asked

Viewed 461 times

0

Would you like to capture several images and "join" them all in one without having to save them first, I capture 6 images put one over the other according to the position on the screen and saved in a single image, would anyone have any idea? I’m using Delphi XE7

function Unir(G1, G2, G3: TGraphic): TBitmap;

begin
  Result := TBitmap.Create;
  with Result do
  try
    Width := Screen.Width;
    Height := Screen.Height;
    Canvas.Draw(0, 0, G1);
    Canvas.Draw(80, 90, G2);
    Canvas.Draw(100, 150, G3);
  except
    FreeAndNil(Result);
    raise;
  end;
end;

That way I can put together 3 images, but I don’t have a fixed amount of images, because they are variable, so in this case the ideal would be to use a array images. I am trying to use the function below, but it gives error when calling them:

Incompatible type Array and Dynamic Array

function UnirTudo(Imagens : array of TGraphic): TBitmap;
var
i : Integer;
begin
  Result := TBitmap.Create;
  with Result do
  try
    Width := Screen.Width;
    Height := Screen.Height;
    for i := 0 to Length(Imagens) - 1 do begin
      Canvas.Draw(0, 0, Imagens[i]);
    end;
  except
    FreeAndNil(Result);
    raise;
  end;
end;
  • 3

    You could give more details, put what you have tried, where you are having trouble. Being more specific increases the chances of getting an answer. Take a look at the [tour] and maybe the [help] to get some help on how to make the most of the site.

  • Then, I was able to merge the images into a single Function Unite(G1, G2, G3: Tgraphic): Tbitmap; Begin Result := Tbitmap.Create; with Result do Try Width := Screen.Width; Height := Screen.Height; Canvas.Draw(0, 0, G1); Canvas.Draw(Image1.Left, Image1.Top, G2); Canvas.Draw(Image2.Left, Image2.Top, G3); except Freeandnil(Result); raise; end; end;

  • But now I wanted to do this using an array of images Function Unirtudo(Images : array of Tgraphic): Tbitmap; var i : Integer; Begin Result := Tbitmap.Create; with Result do Try Width := Screen.Width; Height := Screen.Height; for i := 0 to Length(Images) - 1 of Begin Canvas.Draw(0, 0, Images[i]); end; except Freeandnil(Result); raise; end; end; I’m not sure how to call this function, gives the following message incompatibles types array and Dynamic array

  • Best to always put the information in the question.

No answers

Browser other questions tagged

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