Jump to content
Sign in to follow this  
Guest dko60202

Writing "Strings" in C

Recommended Posts

Guest zip

One way to dim the display is to render the same exact image in GDI+, but using a color transform to brighten or darken the image.The easiest way to do this in GDI+ is to use a color transformation matrix.Example:Graphics* pgCanvas = NULL; // graphics contextbmpImage = new Bitmap(width, height); // render in memorypgCanvas = Graphics::FromImage(bmpImage); // the drawing contextfloat rscale, bscale, gscale;GetColorScale(&rscale,&bscale,&gscale); // current color scale factor (a routine you write)ImageAttributes m_imAtt;ColorMatrix colorMatrix = { rscale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, gscale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, bscale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; m_imAtt.SetColorMatrix(&colorMatrix,ColorMatrixFlagsDefault,ColorAdjustTypeBitmap); pgCanvas->DrawImage(bmpImage,rect,0,0,width,height,UnitPixel,&m_imAtt);Hope this helps,Etienne

Share this post


Link to post
Share on other sites
Guest dko60202

You can also scale the alpha in the same transform matrix (row 4, col 4).Problem is, this scales in rgb-space, which can cause undesirable color shifts. To properly dim a color (other than white/gray), it should be converted to HSB or HLS color-space, where you can scale a single value (Brightness or Luminence) and convert back to rgb.Douglas

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...