 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Marcos Guest
|
Posted: Wed Sep 08, 2004 12:00 am Post subject: How to merge two bmp images and save it into one |
|
|
Hello friends:
Please help. can some body provide small sample code
on how to merge two images bmp then save it into one
single bmp file.
for example: I have two images of a check front and back
I want to merge these two images into one single bmp
under a sinlgle file bmp.
Thank you very much in advance
Marcos
|
|
| Back to top |
|
 |
Wayne Herbert Guest
|
Posted: Wed Sep 08, 2004 2:02 am Post subject: Re: How to merge two bmp images and save it into one |
|
|
Marcos wrote:
| Quote: | Hello friends:
Please help. can some body provide small sample code
on how to merge two images bmp then save it into one
single bmp file.
for example: I have two images of a check front and back
I want to merge these two images into one single bmp
under a sinlgle file bmp.
Thank you very much in advance
Marcos
|
The CopyRect function is what you need.
Assume that you have two bitmaps, Chk1 and Chk2, that hold the images
that you have loaded. You have an output bitmap, Both, that holds each
image. Then:
// stack two images top to bottom in a single bitmap
var
Chk1, Chk2, Both : TBitmap
begin
<load up the front and back check images into their bitmaps>
Both := TBitmap.Create;
If Chk1.Width > Chk2.Width then
Both.Width := Chk1.Width
else
Both.Width := Chk2.Width;
Both.Height := Chk1.Height + Chk1.Height;
Both.Canvas.CopyRect(Rect(0,0,Chk1.Width,Chk1.Height),
Chk1.Picture.Bitmap.Canvas,Rect(0,0,Chk1.Width,Chk1.Height));
Both.Canvas.CopyRect(Rect(0,Chk1.Height,Chk2.Width,Chk2.Height),
Chk2.Picture.Bitmap.Canvas,Rect(0,0,Chk2.Width,Chk2.Height));
Both.SaveToFile('s:tempwowza.bmp');
Both.Free.Free;
|
|
| Back to top |
|
 |
Marcos Guest
|
Posted: Wed Sep 08, 2004 5:15 pm Post subject: Re: How to merge two bmp images and save it into one |
|
|
Mr.Wayne Herbert,
Thank you very much for your fast response, I try the
code you provided and it works GREAT!!!!
Once again thank you sir, I appreciated your help
Marcos
"Wayne Herbert" <wayne (AT) NOSPAMherberts (DOT) org> wrote
| Quote: | Marcos wrote:
Hello friends:
Please help. can some body provide small sample code
on how to merge two images bmp then save it into one
single bmp file.
for example: I have two images of a check front and back
I want to merge these two images into one single bmp
under a sinlgle file bmp.
Thank you very much in advance
Marcos
The CopyRect function is what you need.
Assume that you have two bitmaps, Chk1 and Chk2, that hold the images
that you have loaded. You have an output bitmap, Both, that holds each
image. Then:
// stack two images top to bottom in a single bitmap
var
Chk1, Chk2, Both : TBitmap
begin
load up the front and back check images into their bitmaps
Both := TBitmap.Create;
If Chk1.Width > Chk2.Width then
Both.Width := Chk1.Width
else
Both.Width := Chk2.Width;
Both.Height := Chk1.Height + Chk1.Height;
Both.Canvas.CopyRect(Rect(0,0,Chk1.Width,Chk1.Height),
Chk1.Picture.Bitmap.Canvas,Rect(0,0,Chk1.Width,Chk1.Height));
Both.Canvas.CopyRect(Rect(0,Chk1.Height,Chk2.Width,Chk2.Height),
Chk2.Picture.Bitmap.Canvas,Rect(0,0,Chk2.Width,Chk2.Height));
Both.SaveToFile('s:tempwowza.bmp');
Both.Free.Free;
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|