Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JIMbond21

Come on smart people, HELP ME!!!

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I know there are a lot of smart and knowlegable people that post on this forum, obviously I''m not one of them. I''ve been trying to create a function for drawing transparent bitmaps with windows gdi and nomatter what I do nothing works, I post the functions I use earlier last night, but evidently no one knows anything about windows gdi and transparent bitmaps, and yes I have done a fair amount of research trying to make this stuff work, but so far unsuccesful. So for those smart and knowlegable poeple out there, can you show me how to draw a bitmap with transparent area of any color choice using windows gdi or look at my functions and tell me whats wrong? The post with the functions was "What''s wrong with this???" on page 2.

Share this post


Link to post
Share on other sites
Advertisement
From what I recall, straight GDI doesn''t inherently support tranparent bitmaps.

You may be best trying to use libpng in conjunction with png files; which actually have alpha channels.

gl hf

Share this post


Link to post
Share on other sites
The short answer is you can't do that because GDI does not support transparency, alpha blends, etc. What you have to do is masking. First you have to make what is called a mask image. The mask is a bitmap that is the same dimensions as the image you want to show except it is black and white. You make everything in the mask image that you want to be seen black and everything that you want to be transparent white. In your original image you make the transparent parts black and the parts you want to be seen, well, normal colored.
Now in code, blit the mask to the screen using SRCAND. Then blit your actual image to the screen using SRCINVERT. You now magically have transparency.

EDIT: Ok, I see in your other post you are trying to create the mask on the fly. Maybe the mask is not correct. Have you tried generating the mask image manually?

[edited by - CodeMunkie on August 14, 2003 12:55:38 PM]

Share this post


Link to post
Share on other sites
Hi,

You need to look through the MSDN documentation. Search for "Alpha Blending". Their web-based docs on the subject can be found here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_00h3.asp

Note that this feature isn't supported on all versions of Windows and it does require your bitmaps to be stored in a specific format. The speed will depend on the graphics card's drivers. Most graphics cards now support acceleration of GDI functions, but not all.

--
Sean Timarco Baggaley

(Looking through the rest of the docs they have there, I think they may be describing the GDI API as it currently exists under Windows XP. I'm fairly certain that the Windows 9x series of operating systems never supported this.)

[edited by - stimarco on August 14, 2003 1:06:47 PM]

Share this post


Link to post
Share on other sites

Google also throws up this:

http://www.mvps.org/user32/gditutorial.html

Looks like it may answer your questions more directly.

--
Sean Timarco Baggaley

Share this post


Link to post
Share on other sites
Hi,

If you are interested in doing transparent bitmaps with DirectDraw, which you''ll use eventually. Goto the SWEET SNIPPLETS section of gamedev.net and find a tutorial on "Direct Draw the easy way" or something. Basically this tutorial will teach you to setup DirectDraw easily and use it with ddutil.h.

After that, look through the MSDN DirectDraw 7 documention and learn about color keys. If you look into ddutil.h you''ll see CSurface and CDisplay classes which have a set color key function defined. Looking into that code will teach you how to do transparent blits. And lots of other things. All within a class you can use.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by JIMbond21
The post with the functions was "What''s wrong with this???" on page 2.


<A HREF="http://www.gamedev.net/community/forums/topic.asp?topic_id=174751">Here</A>

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://www.gamedev.net/community/forums/topic.asp?topic_id=174751

Share this post


Link to post
Share on other sites
A good windows GDI tutorial can be found at:

www.gametutorials.com

Just click on the tutorials button and then the link that goes into win32 programming tutorials. It will talk about everything you will probably want to know. Transparent blitting, double buffering, keyboard and mouse input, etc...

Share this post


Link to post
Share on other sites
well u could make ur own alpha blending. use an offscreen buffer for drawing and than blt it to the DC.

look at opengl blending for reference on blending and use that for ur drawing functions - its quite easy

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!