Jump to content
Sign in to follow this  
badderjet

GDI+ and transparency

Recommended Posts

Hello all,is there any way to have semi-transparent gauges with GDI+?What I mean is basically having a black (RGB 0, 0, 0) canvas with the CREATE_DIBSECTION flag, but also the TRANSPARENCY flag. I just do not get it working, after much trying around. It usually draws nothing at all or extremly wild and weird colored images where you can barely recognize the original shapes drawn by GDI+, but as I said, completely wrong/crazy colors and very pixelated, just not as intended.Does anyone here have experience/success with that?I'd greatly appreciate it.Thanks guys,Etienne :-wave

Share this post


Link to post
Share on other sites
Guest bartels

As far as I know GDI and GDI+ can't use transparency. You can add transparency between parts of the same GDI drawing, but not to other image elements or gauges.Arne Bartels

Share this post


Link to post
Share on other sites

Big pity.I was thinking of some kind of GDI+ drawn HUD, since from what I heared someone got something similar working recently with the XML 'vector' stuff.Thanks for the information though. :)Etienne

Share this post


Link to post
Share on other sites

Exactly this is what I mean! Good job by the way. :-hahMay I ask what kind of background bitmap you use (and its image flags like transparency etc. in case those exist in XML)?Or is that not even required in XML? Sorry, I have no idea about the XML gauges, but with GDI(+) you need some kind of background bitmap to draw onto, that is why I am asking.Thank you!Etienne :-wave

Share this post


Link to post
Share on other sites

Etienne,The only bitmap is an image of the HUD frame, but you even don't need that one; is just for the "look".You can use:as a "background" for the xml code.In this case the xml the transparancy command is not needed.I use rectangles with transparancy to "dim and brighten" the various MFD's in my 767-300 panel.Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest zip

Jan, thanks for getting back to me on the subject - much appreciated.I did find a way to duplicate this in GDI+, but it involves drawing directly on the window for that panel, creating your own GDI+ context, and thus effectively creating your own window paint routine. One of the clear advantages is that you do have access to all the anti-aliasing and color matrix transforms this way.The technique also works with DirectX rendering, which is much faster than GDI+, but a little trickier to implement in code, especially for "2d" type stuff. Unless rendering very complex items, probably not worth the boost.

Share this post


Link to post
Share on other sites

>I did find a way to duplicate this in GDI+, but it involves>drawing directly on the window for that panel, creating your>own GDI+ context, and thus effectively creating your own>window paint routine. One of the clear advantages is that you>do have access to all the anti-aliasing and color matrix>transforms this way.What do you mean with that advantage, you usually have access to the anti-alias etc pretty much always when creating a usual GDI+ drawn 'vector' gage, dontcha!? :-eekAlso an interesting observation on DX, by the way.But in general you mean it is indeed possible to 'connect' GDI+ and transparency, huh?Etienne

Share this post


Link to post
Share on other sites
Guest zip

Yes, what I mean by that is that by creating your own context you have much better control over the rendering process in general, including transparency issues, and you can mix/match any graphics tool under Windows (GDI, GDI+ and DirectDraw) as needed.One of the main advantages of painting your own window is that you can render full alpha channels in bitmaps, allowing for interesting shading effects.The paradox with using DirectX for 2D drawing is that the 2D part of DirectDraw was eliminated starting with DX8, and you have to go back to create a DirectX7 canvas to use 2D, or use projections in 3D. When you look at the quantity of code needed vs speed vs GDI+, on the mid-range to high end systems you won't see much of a FPS hit.I think that one of the tricks to performance is to make judicious use of pre-rendered complex backgrounds and sprites in GDI+, and use vectors drawing to provide content on top sparingly.

Share this post


Link to post
Share on other sites

Very cool, thanks for the insight.I have never tried to use DX though, so this is kinda outta my league.Best,Etienne

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...