Board index » delphi » Merging multiple TImages.

Merging multiple TImages.

I have several .BMP files, each holding an image.

I need to create a new .BMP which would be essentially
a filmstrip - it would contain each of the images from the
individual files, one after another.

One would think this would be easy, but when I started
trying to do it, I got stuck fast.  Can anyone help?

Please reply via Email, as well as to the newsgroup.

steph...@airmail.net
http://web2.airmail.net/stephenw/

 

Re:Merging multiple TImages.


Quote
steph...@airmail.net (Stephen Whitis) wrote:
>I need to create a new .BMP which would be essentially
>a filmstrip - it would contain each of the images from the
>individual files, one after another.

a) Create a TBitmap
b) Set its width & height based on the number of images being merged
together
c) Use CopyRect method of Canvas to copy one image into your
"filmstrip bitmap". Refer online help for more info, it's very easy to
use method.

{ let's say you have img1 and its size is ok}
procedure MergeBitmap(sFile : String);
var
mybmp: TBitmap;
rectA, rectB: TRect;
x,y : Integer;
begin
try
  mybmp:=TBitmap.Create;
  mybmp.LoadFromFile(sFile);
  x:=<relative top-left coordinate in a img1 for a new bitmap. Count
the number of images in a filmstrip>
  y:=<relative bottom-right coordinate in a img1 for a new bitmap>
  rectA:=(0,0,mybmp.Width,mybmp.Height);
  rectB:=(x,y,x+mybmp.Width,y+mybmp.Height);
  Img1.Picture.Bitmap.Canvas.CopyRect(rectB,?,?,rectA);
{sorry cant remember all the arguments}
{?!? or was it image1.Picture.Canvas.CopyRect... or
Image1.Canvas.CopyRect...?!? }
finally
  mybmp.Free;
end;
end;

Hope you got some ideas from the code above, which is really an
example of full-of-errors.

Happy coding...

Other Threads