Link to home
Start Free TrialLog in
Avatar of umesh053097
umesh053097

asked on

Bitmaps with a specific color transparent.

I need to have the ability to display a bitmap with a specified color depicting the transparent part of the bitmap. In my case it is pink. If you have any code to do this I would really appreciate it.

I'm using Win16/Win32 API(should work on Win3.1 & 95).

Bitmap is drawn in a dailog box.


Software Used: VC++4.2    for Win32
                       VC++1.52  for Win16

Avatar of stevesm
stevesm

What software are you using, and where do you want to display the bitmap?
Avatar of umesh053097

ASKER

Edited text of question
Sorry, Not much help
Perhaps you should reopen the question to someone else.
I have a source code written in C for a program named transgif. You can list values of all colors in gif and than select one value and make it transparent. Again IT is for gif format only. I'm not sure if it can help you..

Damir
I don't think bitmaps can be transperent. bitmap format (24 bit color, for example), save for any pixel a value of the color (at 24 bit). Because there is no color value for transperency, i don't think bitmaps (bmp) can be transperent. Gif's, on the other hand, can be transperent very easily.
A bitmap itself can't be transparent, but it is quite easy to display it as transparent. Your question is about displaying, so here it goes.

Take a look at BitBlt. Use it to display your image. You have to display your image twice, using a mask-image. Your mask image is a two color image. Use black for the non-transparent colors, the opposite color of your color that has to be transparent as the transparent color. (you  get that by inverting the image in an editor)
First, the mask picture must be copied to the display with the SRCAND as dwRop in BitBlt (the last parameter), second, you use the SRCINVERT as dwRop to display the original image. Both on the same location. As a result your bitmap's color you would like to be transparent shows transparent.

BTW the imagelist can be used as well for displaying pictures transparent, but even than you have to use a mask for that. The problem with the imagelist is that all pictures must be of the same size.

BTW2 using a mask is (by my knowledge) the most common (and fast) way of displaying a bitmap transparent.

Hope this helps you out. For any questions, please place a comment, if this doesn't apply to your problem, reopen the q. for other experts.

Regards, Abel
In Windows95 the defalt transparentcy color is blue 100% blue if your going to make an icon u'd use blue for the transparent part.. i dont know if that helps but it cant hurt...
Abel,
Your answer is the approach I'm currently taking. I have all the bitmaps and their masks too. The only reason I asked the question was, so that I didn't have to create a new mask everytime I got a new bitmap. But thanks anyway.  
Would some code on how to make a mask of a bitmap suffice? Then you can make it at runtime and in memory, so you don't need making the masks by hand.
Yes, I would certainly take a look at it and try it.
If you don't mind I'll post that tomorrow. It's almost night up here, so I'm going home now. I hope that before that no one else will answer this q., otherwise my hours of work would be in vain. :-)

Regards, Abel
In Windows95 the 1,1 pixel is the transparent color. Check if it works for Win3.11 too.

B.P.
Mr B.P

Could you be more elaborate in your suggestion.
When editing colormapped (palette-color) images, many image editors allow you to designate one of the palette colors as "transparent" if the file format permits it.  For example, when
saving a GIF image, Cerious Software's Thumbs Plus allows you to click on "Transparent" and then click somewhere in the image to designate the color which is to be transparent.
I don't have the flexibility of dealing with GIF images only BMPs
I can give you Delphi code to create a transparent bitmap, then you can convert it to C

Let me know ¿ by comment.....

Later

BoRiS
Boris,
I will certainly take a look at it. Even though I don't know Delphi, I think Pascal would be pretty easy to understand. Go ahead and post it.
ASKER CERTIFIED SOLUTION
Avatar of RONSLOW
RONSLOW

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