Sign in to follow this  
n4gix

Lighting a DIBSECTION...

Recommended Posts

I am looking for a way to control whether a GDI+ gauge's drawing surface can be made "BRIGHT" and controllable via the panel lights switch.MAKE_STATIC( vision_image, BMP_VT_BG, NULL, NULL, IMAGE_USE_ERASE|IMAGE_USE_BRIGHT|IMAGE_CREATE_DIBSECTION, 0, MAP_LEFT_BORDER,MAP_TOP_BORDER)While this example is "lighted" via the IMAGE_USE_BRIGHT flag, there's no way to "turn it off."Does anyone have a clue how I can achieve this goal?I had thought that if I used a SLIDER for this, I could then use the callback to control the BRIGHT and DARKEN a la traditional bitmaps, but it seems that I can't use a SLIDER type with the IMAGE_CREATE_DIBSECTION flag.I suppose I should point out that I'm creating an LCD type gauge, and am using a photo of the guage as the BMP_VT_BG image, so it is important that any solution keep that in mind... ;)IOW, I'm only drawing the LCD "segments" of the gauge, NOT the "painted scales, labels and other markings..."

Share this post


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

how about using 2 identical Static Images. The one should use the IMAGE_USE_BRIGHT and the other it shouldn't.MAKE_STATIC(img_var_wb,BMP_WB,NULL,NULL,IMAGE_USE_ERASE|IMAGE_USE_BRIGHT|IMAGE_CREATE_DIBSECTION,0,0,0)// Next element declaration should go here.MAKE_STATIC(img_var_wob,BMP_WOB,next_element,NULL,IMAGE_USE_ERASE|IMAGE_CREATE_DIBSECTION,0,0,0)The button should control img_var_wb by using HIDE_IMAGE and SHOW_IMAGE macros.---------------------------------------------------------------------In the other hand you can use Graphics::FillRectangle method with a black brush with variable alphaFor example: BYTE bDarkenLevel = 255; // <- This should control darkness level SolidBrush DarkenBrush(Color(bDarkenLevel,0,0,0)); Graphics G(hdc); G.FillRectangle(&DarkenBrush,...);This portion of code should be placed last in the drawing algo.

Share this post


Link to post
Share on other sites

No. The first way won't work. If you try to use IMAGE_CREATE_DIBSECTION without IMAGE_USE_BRIGHT, you just get a black bitmap.The best way to lighten/darken a DIB section is to put an alpha channel layer above it for brightness control like in the second example.

Share this post


Link to post
Share on other sites

>No. The first way won't work. If you try to use>IMAGE_CREATE_DIBSECTION without IMAGE_USE_BRIGHT, you just get>a black bitmap.>>The best way to lighten/darken a DIB section is to put an>alpha channel layer above it for brightness control like in>the second example.That would be true Hans, IF I was not using an actual "photograph" for the background image. I'm building a Vision Microsystems LCD engine cluster. The "scales" and "legends" are printed on the plastic cover for the LCD screen, and there's a nice "reflective sheen" to the plastic that I don't wish to lose... ;)Of course, that is the very reason why the second method wouldn't work for me either... ;)I solved the problem by simply creating a SLIDER and switching a copy of the background image on/off as a "cover." Further, to mask the tiny bits of the corners that overlap the bezel when the background is backlighted, I added another SLIDER with just the bezel.However, I do use method #2 for other GDI+ gauges that are wholly drawn on a blank background. It's quite effective.Doug Dawson sent me a unique solution to the question, which I'm including below just for sake of completness... ;)case PANEL_SERVICE_PRE_DRAW: lookup_var(&panel_lights); if ( lights_now != panel_lights.var_value.n ) { if ( panel_lights.var_value.n == 1 ) {bg_element->image_flags |= IMAGE_USE_BRIGHT;} else if ( panel_lights.var_value.n == 0 ) {bg_element->image_flags &= ~IMAGE_USE_BRIGHT;} REDRAW_IMAGE(bg_element); lights_now = panel_lights.var_value.n; }break;This works only to change the flag for the static. For some reason, bg_element->next_element->image_flags is not valid and will not allow the gauge to compile...http://forums.avsim.net/user_files/124232.jpg

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