问题
I want to draw on a window. To do that I created several brushes. For testing I used a normal red (255, 0, 0). Now I want to use more specific color like a 198, 17, 17 red. I am creating the brush like this:
SolidColorBrush _redBrush = new SolidColorBrush(_device, new RawColor4(198, 17, 17, 1));
When I now draw in the window it is not red instead it is just white. Could anyone please tell me what is wrong with this and how I can draw with the color I actually want?
Sorry if this is a really simple question but I am not very experienced with DirectX. Also thanks for your help.
回答1:
Colors should be a percentage (in this scenario), so 1.0 is equivalent to 100%. When you tested 255,0,0 you saw red because you send 0 to green and blue channels and 255 or 25500% to the red channel, the same result could be achieved with (1,0,0).
Change your values to percentage between 0 and 1 -> (198/255,17/255,17/255,1) The same apply for alpha channel so 1 is no transparency and 0 is full transparency.
回答2:
RawColor4
expects float values which is between 0 and 1.
来源:https://stackoverflow.com/questions/64266650/directx-c-sharp-solidbrush-is-drawing-white