Making Parts of Bitmap image transparent

andrewo
06-27-2001, 01:49 AM
Hey I was wondering on how to make parts of a bitmap image transparent.

Like you have a bitmap picture with a red background and a blue box in the middle

I want to make the red back ground transparent to anything it is placed on in the form.
eg. another image.

And another question is
with the blue box and red background
can you change the value of the colour as it is bitmap and make the red look green when the bitmap picture is opened in the form.

~

Laurent
07-03-2001, 11:57 AM
i needed to do that on an html page with a background, so i use corelDraw an selected a color to change it to transparant...hope this helps you!!

for the open box, i don't think it's possible to change an image at run time, maybe you could create two boxes one red and one green and load different one deoending on the situation.

I'll be among the best soon, very soon!!!

orufet
07-08-2001, 08:23 PM
The answer to your question is that it's impossible. You cannot make part of a bitmap image transparent. No way. If you figure out how to do that, I'll pay you $100,000....

You need to use a jpeg or gif and play around with Photoshop or whatever, you'll figure it out

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once

chris1234
07-09-2001, 05:55 AM
How is it impossible. I dont know if you were joking or if you are looking for something else but Here is a sample program

Garrett Sever
07-09-2001, 06:34 AM
Whatever you do, DO NOT USE HIS CODE.

Not b/c there is a virus or anything, but because the TransparentBlt API has a memory leak. If you don't believe me, I'll send you the code that proves it.

Instead you should use a mask image and use BitBlt. Its slower, there are more calls, but there is no memory leak.

-Hand out.

"On a long enough timeline, everyone's life expectancy drops to zero." - Fight Club

orufet
07-09-2001, 09:37 PM
Chris1234: You did not make the bitmap transparent!!!! All you did was make the image LOOK transparent on the Form. I opened up the File and it was still normal!! I was talking about actually making the image itself transparent

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once

ofahad
07-10-2001, 03:21 AM
can u send the code for your method?

If you lost your left arm, your right arm would be left. ;)

chris1234
07-10-2001, 04:48 AM
Hello,
Sorry about that memory leak or whateva it was, cause I really havent had ne problems with it. Any way you can put the image on top of a different image and you can still see the other image behind it in the blank spots. R u talking about making the image transparent in your program or actually making the bitmap transparent.

Ad1
07-10-2001, 05:38 AM
Orufet, do you work for an insurance company by any chance images/icons/wink.gif hehe

ofahad
07-10-2001, 06:20 AM
hey I tried using your code but it does not work on my picture. can you tell me what picture1.hdc mean? you are taking the color for transparency from the picture's 0,0 position? can you explain the code in more detail since it is going way over my head :)

and can this code work on an imagebox? if not then what I insert an image inside a picturebox?


If you lost your left arm, your right arm would be left. ;)

orufet
07-10-2001, 09:44 AM
Actually, I'm a laywer images/icons/smile.gif

Naw, I'm just a high school student

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once

andrewo
07-11-2001, 10:28 PM
cool thanx for all the replies
betting 100,000 hmmm

~

andrewo
07-17-2001, 12:30 AM
Hey I ran the program despite your warnings :)
But what does the memory leak do?
the program works...
is there a better way to make it transparent?

Having the picture transparent on the form is basically transparency anyway.....

~

orufet
07-17-2001, 01:25 AM
Yup. I am betting that much, because to do it, you'd have to change something about the format of the image. Which means it's no longer the original bmp file...and therefore you didn't do it....:)

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once

Garrett Sever
07-17-2001, 06:43 PM
The TransparentBlt function has a memory leak that slowly chews up system and GDI resources until there aren't anymore available.

Eventually your program will crash and you will have to close it down. Fortunately windows should reclaim the resources as soon as your program thread stops, but that's not for certain.

I've attached an example program to demonstrate my program. I got critically low on resources after 300 or so TransparentBlts. If you are going to be writing a game, you will be doing ALOT more than that.

Regards,
-The Hand

"On a long enough timeline, everyone's life expectancy drops to zero." - Fight Club

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum