Link to home
Start Free TrialLog in
Avatar of Cheng_sam
Cheng_sam

asked on

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.
Avatar of mokule
mokule
Flag of Poland image

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.
Avatar of Cheng_sam
Cheng_sam

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it's O.K.thanks  for TheRealLoki and mokule .