CMCHTPC / DelphiDX12

DirectX 12 Headers for Delphi and FPC
92 stars 35 forks source link

D2D1 color definitions #16

Closed FactoryXCode closed 3 years ago

FactoryXCode commented 5 years ago

The color definitions in the D2D1Helper section are wrong. For example: DarkSlateGray = $2F4F4F; // >> #2F4F4F works Ok in C++, but not in Delphi should be DarkSlateGray = $004F4F2F; // the correct Delphi TColor equivalent to DarkSlateGray You can check this by enter the TColorvalue to a TForm.color. I think the colorfields r and b are mixed up in Delphi. A correct translation from TColor to D3DCOLORVALUE:

function D2D1TColorF(dcolor: TColor; {opacity} a: Single = 1.0): TD2D1ColorF; begin Result.r := ((dcolor AND $00FF0000) shr 16) / 255; Result.g := ((dcolor AND $0000FF00) shr 8) / 255; Result.b := ((dcolor AND $000000FF)) / 255; Result.a := a; end;

luebbe commented 4 years ago

Yes, you always need to swap the R&B bytes in Delphi

CMCHTPC commented 3 years ago

Color definition is from GDI+ header. Correct value for DarkSlateGray = $FF2F4F4F; D2D Colors are always ARGB. ARGB values are updated in the new release.