Come on smart people, HELP ME!!!

Started by
16 comments, last by JIMbond21 20 years, 8 months ago
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.
THX,JAP
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
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]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
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]
Sean Timarco Baggaley (Est. 1971.)Warning: May contain bollocks.

Google also throws up this:

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

Looks like it may answer your questions more directly.

--
Sean Timarco Baggaley

Sean Timarco Baggaley (Est. 1971.)Warning: May contain bollocks.
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.
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>
http://www.gamedev.net/community/forums/topic.asp?topic_id=174751
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...
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

This topic is closed to new replies.

Advertisement