BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to merge two bmp images and save it into one

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Marcos
Guest





PostPosted: Wed Sep 08, 2004 12:00 am    Post subject: How to merge two bmp images and save it into one Reply with 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


Back to top
Wayne Herbert
Guest





PostPosted: Wed Sep 08, 2004 2:02 am    Post subject: Re: How to merge two bmp images and save it into one Reply with quote



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





PostPosted: Wed Sep 08, 2004 5:15 pm    Post subject: Re: How to merge two bmp images and save it into one Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.