KEMBAR78
ColorTranslator.ToWin32 is inefficient · Issue #105992 · dotnet/runtime · GitHub
Skip to content

ColorTranslator.ToWin32 is inefficient #105992

@JeremyKuhne

Description

@JeremyKuhne

Known colors are looked up with every property access. With system colors on windows this will cause 3 PInvokes.

public static int ToWin32(Color c)
{
return c.R << COLORREF_RedShift | c.G << COLORREF_GreenShift | c.B << COLORREF_BlueShift;
}

Need to grab the full ARGB value and work with it instead to limit to a single lookup.

Metadata

Metadata

Assignees

Labels

area-System.DrawingenhancementProduct code improvement that does NOT require public API changes/additionsin-prThere is an active PR which will close this issue when it is mergedtenet-performancePerformance related issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions