Sign in to follow this  
Guest Jon_Gibbs

Changing Alpha values in GDI+

Recommended Posts

Hi,There are a lot of examples of how to change colors in a bmp in GDI+ and the Color class does contain a method to set a new value.However I have tried this many times and had no luck.Here is the algorithmByte Brightness = 0xFF; Color green(brightness, 0x00, 0xFF, 0x00);rendergauge{...Make argb (brigness, ....) --this is in the the sdkgreen.setvalue(argb);}Mousefunctionbrightdownbrightness--;Any ideas? Has anyone else managed to do this?Also has anyone been successful in making their own class defenitions and methods in FS9? Mine compiles and runs but once you press alt, FS9 exits.ThanksJon

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I'm not at home at the moment, I'll have to check in detail later. The problem of exiting on "ALT" looks, as if you "hook" to the bitmap in the wrong time. You can't use PANEL_SERVICE_CONNECT_TO_WINDOW and PANEL_SERVICE_DISCONNECT for hooking to the MAKE_STATIC, since the pointers get invalid on resizing, these both service_ids are only for starting/stopping GDI+. You can either use all GDI+ drawing code in the PANE_SERVICE_PRE_DRAW or choose the the servide_ids for contructiing/destructing with care.Arne Bartels

Share this post


Link to post
Share on other sites

Hi Arne,Im not sure what you mean by "hooking the bitmap" but I do have code in those to functions for things other then gdi+ (mainly for initialization destruction of my own class objects). Also it looks like my drawing functions are only being called once and not updating with time. They do resize approriatly when they need to but other then that, it looks like they are only being called once.Any ideas?Thanksjon

Share this post


Link to post
Share on other sites

So are you just trying to change the alpha of a bitmap, before drawing it?If so, try using a colormatrix. I used something like this to turn my bitmap into an alpha shadow:ImageAttributes ia;ColorMatrix colorMatrix = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, .50f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};ia.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);

Share this post


Link to post
Share on other sites

No,I want to change the alpha value of a color for a pen. Not a bitmap.

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