Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

GDI color picker not working

Open bmuessig opened this issue 3 years ago • 6 comments

The color matrix of the color picker is not rendered in the GDI binding: grafik

I believe that the following method is not completely implemented: https://github.com/Immediate-Mode-UI/Nuklear/blob/master/demo/gdi/nuklear_gdi.h#L240

bmuessig avatar May 02 '22 23:05 bmuessig

I believe this is an issue with transparency handling.

Drawing the color gradient works fine: https://github.com/Immediate-Mode-UI/Nuklear/blob/master/src/nuklear_color_picker.c#L108 The transparent black gradient in the next line does not work and always completely blacks out the color gradient.

bmuessig avatar May 12 '22 12:05 bmuessig

Okay, I see the issues:

  1. nk_gdi_set_vertexColor does not respect alpha and also only bitshifts to convert 8 to 16 bit color components
  2. Alpha blending is not working properly in GDI
  3. There is no double buffering to a 32-bit RGBA surface

bmuessig avatar May 12 '22 13:05 bmuessig

I don't think there is a quick fix for this. GDI (without plus) does not appear have enough alpha support to make this feature work. Even with double buffering and alpha blending instead of bit blitting, the alpha channel is simply ignored. This also makes me wonder, if transparent images are supported either. My best guess would be that they don't work.

I've still made a few improvements in this PR: https://github.com/Immediate-Mode-UI/Nuklear/pull/460

bmuessig avatar May 12 '22 15:05 bmuessig

It seems that AlphaBlend has a critical limitation: If the source and destination are the same surface, that is, they are both the screen or the same memory bitmap and the source and destination rectangles overlap, an error occurs and the function returns FALSE.

Source: https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-alphablend#remarks

GetLastError() after AlphaBlend() returns error code 87 == ERROR_INVALID_PARAMETER

BraynStorm avatar May 28 '22 13:05 BraynStorm

Nevermind, I'm blind... They are not the same, but the error returned is still there.

BraynStorm avatar May 28 '22 14:05 BraynStorm

Moreover, GetDeviceCaps(gdi.window_dc, SHADEBLENDCAPS) == SB_NONE indicates that the context doesn't support blending. WTF?

BraynStorm avatar May 28 '22 14:05 BraynStorm