?
Solved

overlay two bitmap images

Posted on 2003-02-27
5
Medium Priority
?
995 Views
Last Modified: 2010-04-04
Does anyone know how to overlay a bitmap image on the another one?
Thanks,
Heesu.
0
Comment
Question by:Heesu
[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
  • Learn & ask questions
5 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 8032261
Hi,

Place two TImage components on a form, load bitmaps to them and try this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Image1.Picture.Bitmap.Canvas.Draw(50,50, Image2.Picture.Bitmap);
end;

Regards, Geo
0
 
LVL 2

Expert Comment

by:Tvigep
ID: 8032406
Hi there,

you can use the CopyRect function of a Canvas, and set the  Canvas.CopyMode to the desired effect (XOR, OR, etc...) :

procedure TForm1.Cut1Click(Sender: TObject);
var
  ARect: TRect;
begin
  Copy1Click(Sender); { do the same thing as the copy menu item }
  with Image.Canvas do
  begin
    CopyMode := cmWhiteness;
    ARect := Rect(0, 0, Image.Width, Image.Height);
    CopyRect(ARect, Image.Canvas, ARect);
    CopyMode := cmSrcCopy; { restore the copy mode }
  end;
end;

HTH,
Stef
0
 

Author Comment

by:Heesu
ID: 8038889

My BaseImage has color in it.
OverlayImage has WhiteandBlack.
I want to show black lines only of OverlayImage on the BaseImage.
Not just cover the BaseImage.

TviGep:

Sorry, I am not an expert.
Can you show me any example in detail.
about Copy1Click and etc.
Thanks,

Heesu.
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 200 total points
ID: 8039567
hello Heesu, I would use the API BitBlt( ) function, with is function you can tell it how you want to combile the colors of the Bitmaps I use the dwRop flag value of SRCAND, so only the Black pixels of the B&W bitmap are drawn -


procedure TForm1.Button1Click(Sender: TObject);
var
ColorBmp, BWBmp: TBitmap;
begin
ColorBmp := TBitmap.Create;
BWBmp := TBitmap.Create;
try
  ColorBmp.LoadFromFile('E:\Color1.bmp');
  BWBmp.LoadFromFile('E:\BW1.bmp');
  BWBmp.PixelFormat := pf1bit;
  BitBlt(ColorBmp.Canvas.Handle,0,0,BWBmp.Width, BWBmp.Height,
         BWBmp.Canvas.Handle,0,0, SRCAND);
  Canvas.Draw(100,200, ColorBmp);
  finally
  ColorBmp.Free;
  BWBmp.Free;
  end;
end;


- - - - - - - - - - - - - - - - - - - - -
understanding the Boolean operations of combining colors takes some getting used to
ask questions if you need more info
0
 

Author Comment

by:Heesu
ID: 8041127
Slick812:

Thanks a lot.
That's what I wanted to see.

Heesu.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question