Solved

make a tranparent bmp ??

Posted on 1999-01-06
4
390 Views
Last Modified: 2013-11-19
how can i make a bmp transparent so i can merge it with another bmp ?
0
Comment
Question by:de_ep
[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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1354847

Dynamically drawing a transparent image
Question:
How do I use a TImageList component to dynamically draw a transparent image?
Answer:
The following example demonstrates the dynamic creation of a
TImageList component used to draw a transparent bitmap.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  bm : TBitmap;
  il : TImageList;
begin
  bm := TBitmap.Create;
  bm.LoadFromFile('C:\DownLoad\TEST.BMP');
  il := TImageList.CreateSize(bm.Width,
                              bm.Height);
  il.DrawingStyle := dsTransparent;
  il.Masked := true;
  il.AddMasked(bm, clRed);
  il.Draw(Form1.Canvas, 0, 0, 0);
  bm.Free;
  il.Free;
end;


Tell me if this helped
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1354848
You can simply set "bitmap.transparent:=true".
If you do nothing but this, all colors that have the same color like the color in the pixel "bitmap.canvas.pixels[0,bitmap.height]" are now transparent.
If you want to decide which color is to be transparent, simply write "bitmap.transparentColor:=clWhite".

Regards, Madshi.
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1354849
A little more detail to help you ...

There actually is no such thing as a transparent BMP file (unfortunately). The transparency comes in when you are drawing the image.

Some formats such as GIF does support transparency but once again it is implemented at draw-time similar to what Mirkwood suggested.

This is usually done by marking one of the pallette entries as the transparent entry. Any pixels of this color will then be deemed to be transparent and not printed on the screen.

What Mirkwood is doing up here is exactly that. He is setting clRed as the mask color and setting DrawingStyle := dsTransparent will tell Delphi not to draw any pixels that are red in the image, thus giving a transparent image.

0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
ID: 1354850
see comment
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this Micro Tutorial viewers will learn how to remove an unwanted object using Photoshop’s feature known as content-aware fill.
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
Suggested Courses

628 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