Transparency 
Author Message
 Transparency

I have been able to successfully create completely transparent areas of a
bitmap by using something like:

    Set g_RedDotTex = g_D3DX.CreateTextureFromFileEx( _
                            g_D3DDevice, _
                            App.Path + "\devices\d_reddot.bmp", _
                            D3DX_DEFAULT, _
                            D3DX_DEFAULT, _
                            D3DX_DEFAULT, _
                            0, _
                            D3DFMT_UNKNOWN, _
                            D3DPOOL_MANAGED, _
                            D3DX_FILTER_POINT, _
                            D3DX_FILTER_POINT, _
                            &HFF000000, _
                            ByVal 0, _
                            ByVal 0)

and then enableing transparency using:

    g_D3DDevice.SetRenderState _
                     D3DRS_ALPHABLENDENABLE, 1

but I cannot seem to figure out how to create "semi" transparent
textures/pixels.  Can anyone give me a short piece of sample code that will
do what I am trying to do, which is to create a semi-transparent surface,
like a window?  Is it the image that is the problem?  It seems like this
would be fairly common and the code for it would be easy to find, but I have
had no luck.
Thanks in advance.



Sun, 23 May 2004 12:02:28 GMT  
 Transparency
You need to use a texture format that keeps track of transparency
information instead of a BMP file. Try using the Targa (.TGA)
format to save an image with 32 bits per pixel which has 8 bits
for each of red, blue and green, plus another 8 bits that contain
the transparency value (alpha) for each pixel.

        .........Wayne

--

Recycling electrons into words since 1996.
Visit www.JustPC.com for details about my Visual Basic books,
including
my newest: Windows Game Programming With Visual Basic and DirectX,
and the ASP.NET Database Programming Bible.


Quote:
> I have been able to successfully create completely transparent
areas of a
> bitmap by using something like:

>     Set g_RedDotTex = g_D3DX.CreateTextureFromFileEx( _
>                             g_D3DDevice, _
>                             App.Path + "\devices\d_reddot.bmp",
_
>                             D3DX_DEFAULT, _
>                             D3DX_DEFAULT, _
>                             D3DX_DEFAULT, _
>                             0, _
>                             D3DFMT_UNKNOWN, _
>                             D3DPOOL_MANAGED, _
>                             D3DX_FILTER_POINT, _
>                             D3DX_FILTER_POINT, _
>                             &HFF000000, _
>                             ByVal 0, _
>                             ByVal 0)

> and then enableing transparency using:

>     g_D3DDevice.SetRenderState _
>                      D3DRS_ALPHABLENDENABLE, 1

> but I cannot seem to figure out how to create "semi" transparent
> textures/pixels.  Can anyone give me a short piece of sample
code that will
> do what I am trying to do, which is to create a semi-transparent
surface,
> like a window?  Is it the image that is the problem?  It seems
like this
> would be fairly common and the code for it would be easy to
find, but I have
> had no luck.
> Thanks in advance.



Sun, 23 May 2004 22:49:57 GMT  
 Transparency
I tried that, but it did not work.  I am sure I am missing some code
somewhere, but I do not know where.  Could you (or someone) please post the
few lines of required code to display a tga with transparency enabled?
Thanks in advance.



Quote:
> You need to use a texture format that keeps track of transparency
> information instead of a BMP file. Try using the Targa (.TGA)
> format to save an image with 32 bits per pixel which has 8 bits
> for each of red, blue and green, plus another 8 bits that contain
> the transparency value (alpha) for each pixel.

>         .........Wayne

> --

> Recycling electrons into words since 1996.
> Visit www.JustPC.com for details about my Visual Basic books,
> including
> my newest: Windows Game Programming With Visual Basic and DirectX,
> and the ASP.NET Database Programming Bible.



> > I have been able to successfully create completely transparent
> areas of a
> > bitmap by using something like:

> >     Set g_RedDotTex = g_D3DX.CreateTextureFromFileEx( _
> >                             g_D3DDevice, _
> >                             App.Path + "\devices\d_reddot.bmp",
> _
> >                             D3DX_DEFAULT, _
> >                             D3DX_DEFAULT, _
> >                             D3DX_DEFAULT, _
> >                             0, _
> >                             D3DFMT_UNKNOWN, _
> >                             D3DPOOL_MANAGED, _
> >                             D3DX_FILTER_POINT, _
> >                             D3DX_FILTER_POINT, _
> >                             &HFF000000, _
> >                             ByVal 0, _
> >                             ByVal 0)

> > and then enableing transparency using:

> >     g_D3DDevice.SetRenderState _
> >                      D3DRS_ALPHABLENDENABLE, 1

> > but I cannot seem to figure out how to create "semi" transparent
> > textures/pixels.  Can anyone give me a short piece of sample
> code that will
> > do what I am trying to do, which is to create a semi-transparent
> surface,
> > like a window?  Is it the image that is the problem?  It seems
> like this
> > would be fairly common and the code for it would be easy to
> find, but I have
> > had no luck.
> > Thanks in advance.



Mon, 31 May 2004 21:17:00 GMT  
 Transparency
You could try to play around with your blending modes, using the
CONST_D3DBLEND enumerations for D3DRS_SRCBLEND
and D3DRS_DESTBLEND. You could also try explicitly setting
a image format that contains alpha, such as A8R8G8B8.

Your problem is most likely getting the alpha information into the
image file itself. With photoshop, you create a 4th channel and use
this for your alpha information. Use shades of grey to describe
different levels of transparency.

Eric

"A good traveller has no fixed plans and is not intent on arriving."
   -Lao Tzu (570 - 490 BC)


Quote:
> I tried that, but it did not work.  I am sure I am missing some code
> somewhere, but I do not know where.  Could you (or someone) please post
the
> few lines of required code to display a tga with transparency enabled?
> Thanks in advance.



Tue, 01 Jun 2004 02:42:17 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to code transparency forms with transparency bitmaps ?

2. usercontrol transparency??? picturebox transparency???

3. Export GIF Transparency

4. Comand Button Transparency

5. Help with Transparency (Opacity) in Windows Forms.

6. User form transparency for car game

7. Transparency and Controls

8. usercontrol or picturebox transparency

9. Form transparency

10. The infamous transparency problem

11. Saving with transparency level

12. Transparency - image - png 32bit - workaround needed...

 

 
Powered by phpBB® Forum Software