Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

overlay two bitmap images

Posted on 2003-02-27
5
Medium Priority
?
1,103 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
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 35

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

572 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