Solved

# Combine to images

Posted on 2001-09-11
173 Views
Hi

How can I combine two Bitmaps taking into account that the first image should be used as background and I wanna point transparent color for the second one.
0
Question by:vterekh
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
1 Comment

LVL 2

Accepted Solution

bugroger earned 30 total points
ID: 6474787
Hi,

Try this function:

//Bitmap2 will be copied with a transparent color (TransColor) on Bitmap1 at Pos(pX, pY)
//Result is the combined bitmap
Function CombineBitmaps(Bitmap1, Bitmap2 : TBitmap; pX, pY : Integer; TransColor : TColor) : TBitmap;
VAR
DummyBitmap : TBitmap;

Begin
Result        := TBitmap.Create;
Result.Width  := Bitmap1.Width;
Result.Height := Bitmap1.Height;
Result.Canvas.Draw(0,0, Bitmap1);

DummyBitmap := TBitmap.Create;
DummyBitmap.Width := Bitmap2.Width;
DummyBitmap.Height := Bitmap2.Height;
DummyBitmap.Canvas.Draw(0,0, Bitmap2);

DummyBitmap.TransparentMode  := tmFIXED;
DummyBitmap.TransparentColor     := TransColor;
DummyBitmap.Transparent      := TRUE;

Result.Canvas.Draw(pX, pY, DummyBitmap);
DummyBitmap.Free;
End;

GL
Bug
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
###### Suggested Courses
Course of the Month3 days, 7 hours left to enroll