Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > Making Parts of Bitmap image transparent


Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2001, 02:49 AM
andrewo
Guest
 
Posts: n/a
Default Making Parts of Bitmap image transparent


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.

~
Reply With Quote
  #2  
Old 07-03-2001, 12:57 PM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: Making Parts of Bitmap image transparent

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!!!
__________________
Still tons to learn!
Reply With Quote
  #3  
Old 07-08-2001, 09:23 PM
orufet's Avatar
orufet orufet is offline
Paranoid Coder

Retired Leader
 
Join Date: Mar 2001
Location: Canada
Posts: 2,716
Default Re: Making Parts of Bitmap image transparent

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
Reply With Quote
  #4  
Old 07-09-2001, 06:55 AM
chris1234
Guest
 
Posts: n/a
Cool Re: Making Parts of Bitmap image transparent

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

Reply With Quote
  #5  
Old 07-09-2001, 07:34 AM
Garrett Sever's Avatar
Garrett Sever Garrett Sever is offline
Strange Brewer

Retired Moderator
* Guru *
 
Join Date: Jun 2001
Location: AddressOf Insomnia
Posts: 2,815
Default Re: Making Parts of Bitmap image transparent

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
__________________
"The lights below
You know they'll bleed forever
Get back as the cores blow
Let me fall..." - Dismantled, "Cornered"
Reply With Quote
  #6  
Old 07-09-2001, 10:37 PM
orufet's Avatar
orufet orufet is offline
Paranoid Coder

Retired Leader
 
Join Date: Mar 2001
Location: Canada
Posts: 2,716
Default Re: Making Parts of Bitmap image transparent

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
Reply With Quote
  #7  
Old 07-10-2001, 04:21 AM
ofahad
Guest
 
Posts: n/a
Default Re: Making Parts of Bitmap image transparent

can u send the code for your method?

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

Reply With Quote
  #8  
Old 07-10-2001, 05:48 AM
chris1234
Guest
 
Posts: n/a
Default Re: Making Parts of Bitmap image transparent

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.

Reply With Quote
  #9  
Old 07-10-2001, 06:38 AM
Ad1 Ad1 is offline
Senior Contributor

Retired Moderator
* Expert *
 
Join Date: Feb 2001
Location: UK
Posts: 1,287
Default Re: Making Parts of Bitmap image transparent

Orufet, do you work for an insurance company by any chance [img]images/icons/wink.gif[/img] hehe

Reply With Quote
  #10  
Old 07-10-2001, 07:20 AM
ofahad
Guest
 
Posts: n/a
Cool Re: Making Parts of Bitmap image transparent

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.

Reply With Quote
  #11  
Old 07-10-2001, 10:44 AM
orufet's Avatar
orufet orufet is offline
Paranoid Coder

Retired Leader
 
Join Date: Mar 2001
Location: Canada
Posts: 2,716
Default Re: Making Parts of Bitmap image transparent

Actually, I'm a laywer [img]images/icons/smile.gif[/img]

Naw, I'm just a high school student

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once
Reply With Quote
  #12  
Old 07-11-2001, 11:28 PM
andrewo
Guest
 
Posts: n/a
Default Re: Making Parts of Bitmap image transparent

cool thanx for all the replies
betting 100,000 hmmm

~
Reply With Quote
  #13  
Old 07-17-2001, 01:30 AM
andrewo
Guest
 
Posts: n/a
Default What memory leak?

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.....

~
Reply With Quote
  #14  
Old 07-17-2001, 02:25 AM
orufet's Avatar
orufet orufet is offline
Paranoid Coder

Retired Leader
 
Join Date: Mar 2001
Location: Canada
Posts: 2,716
Default Re: Making Parts of Bitmap image transparent

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
Reply With Quote
  #15  
Old 07-17-2001, 07:43 PM
Garrett Sever's Avatar
Garrett Sever Garrett Sever is offline
Strange Brewer

Retired Moderator
* Guru *
 
Join Date: Jun 2001
Location: AddressOf Insomnia
Posts: 2,815
Default Re: What memory leak?

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
__________________
"The lights below
You know they'll bleed forever
Get back as the cores blow
Let me fall..." - Dismantled, "Cornered"
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->