June 8, 200520 yr 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
June 8, 200520 yr 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
Create an account or sign in to comment