Skip to content

Add ToHex method to Argb32 #2963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

lindexi
Copy link

@lindexi lindexi commented Jul 3, 2025

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Add ToHex method to Argb32.

The Argb32 will use the AARRGGBB format. Which format is what the WPF and WinUI and MAUI and Avalonia and so on used.

See #2962

@CLAassistant
Copy link

CLAassistant commented Jul 3, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

? ('F', hex[0], hex[1], hex[2])
: (hex[0], hex[1], hex[2], hex[3]);

return new string(new[] { a, a, r, r, g, g, b, b });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocates more than needed. Instead the string.Create-overload could be used, where you can pass in a state and operate on the string-buffer directly, thus avoiding any intermediate allocation.

Although for .NET 10 the JIT will maybe stack-alloc the intermediate array allocation, but I'm not sure if this is actually the case here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants