Skip to content

Commit d7709ee

Browse files
Fix Color.ToHex()
1 parent 037d6ea commit d7709ee

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/ImageSharp/Color/Color.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,17 @@ public Color WithAlpha(float alpha)
251251
/// </summary>
252252
/// <returns>A hexadecimal string representation of the value.</returns>
253253
[MethodImpl(InliningOptions.ShortMethod)]
254-
public string ToHex() => this.data.ToRgba32().ToHex();
254+
public string ToHex()
255+
{
256+
if (this.boxedHighPrecisionPixel is not null)
257+
{
258+
Rgba32 rgba = default;
259+
this.boxedHighPrecisionPixel.ToRgba32(ref rgba);
260+
return rgba.ToHex();
261+
}
262+
263+
return this.data.ToRgba32().ToHex();
264+
}
255265

256266
/// <inheritdoc />
257267
public override string ToString() => this.ToHex();

0 commit comments

Comments
 (0)