Home > OS >  How come Gdiplus SolidBrush's RGB is different from regular RGB?
How come Gdiplus SolidBrush's RGB is different from regular RGB?

Time:10-01

I'm trying to paint a simple header on top of my Window with Gdiplus' SolidBrush, but whenever I set the RGB color it's different from what it's suppose to be.

How come this is happening? And is there a way to fix that? Thanks!

Gdiplus' SolidBrush RGB:

enter image description here

Regular RGB:

enter image description here

CodePudding user response:

You are using the Color constructor taking four arguments, a, r, g, and b, in this order. (255, 255, 0, 0) thus means: Fully opaque (first value), red channel at full intensity (second value), and no contribution from other color channels.

In other words: You're creating a fully opaque red brush as illustrated in the application screenshot.

If you wish to create a Color value from the color channels only, there's a convenience constructor taking r, g, and b arguments. The opacity is implied to be 255 (i.e. fully opaque).

Gdiplus::SolidBrush brush(Gdiplus::Color(255, 255, 0));

creates a fully opaque, bright yellow brush.

  • Related