combined two bitmap

Experts:
      I plot two bitmap in my program.     I try to combine two bitmap into one.
one is for  background and the others is foreground.     How to?thanks.
Cheng_samAsked:
Who is Participating?
 
TheRealLokiSenior DeveloperCommented:
This link shows you how to combine images
(background and foreground)
There is source, and a good example
http://www.delphiforfun.org/Programs/Delphi_Techniques/maskdrawing.htm
0
 
mokuleCommented:
You are not precise in Your question.
So I can't be in an answer.

However You can combine two bitmaps like below

  image3.Canvas.Draw(0,0,Image1.Picture.Bitmap);
  image3.Canvas.CopyMode := cmSrcPaint;
  image3.Canvas.Draw(0,0,Image2.Picture.Bitmap);

You can play with copymode to achieve desied results.
0
 
Cheng_samAuthor Commented:
thanks for mokule's comment.

 I plot something in image2 and image3 as follow:
     image2.transparent:=true;
     image3.transparent:=true;
     with  image2.Canvas  do begin
           Pen.Width :=4;
           Brush.Style:= bscross;//
           SetBkColor(image2.Canvas.Handle, clred); //
           SetBkMode(image2.Canvas.Handle, OPAQUE);
           Rectangle(20,20,300,300);
           MoveTo(0, 0);
           LineTo(500, 500);
    end;
    with  image3.Canvas  do begin
          Pen.Color :=clblue;
          Pen.Width:=14;
          Brush.Color := clBlack;
          SetBkColor(image3.Canvas.Handle, clred);
          SetBkMode(image3.Canvas.Handle, OPAQUE);
          Brush.Style := bsDiagCross;  
          Ellipse(50, 50, 150, 150);    
          MoveTo(200,0);
          LineTo(0,200);
     end;
     self.Canvas.Draw(0,0,Image3.Picture.Bitmap);
     self.Canvas.CopyMode := cmSrcPaint;
     self.Canvas.Draw(0,0,Image2.Picture.Bitmap);
        the result is image2 always cover the image3. But I need the image2 show with image3 simultaneously.That is
     image2 is transparent and I can be seen image3's graphic .
      But  it  seem can't do.How to improve?Thanks.
0
 
Cheng_samAuthor Commented:
it's O.K.thanks  for TheRealLoki and mokule .
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.