From b84ac8528fe3bfbaaac6fb596b071736593d2fd1 Mon Sep 17 00:00:00 2001 From: Ygor Souza Date: Mon, 9 Sep 2024 19:12:11 +0200 Subject: [PATCH] Use native endianness instead of big endian The table is built at runtime and used locally, so the endianness will always be the same on both sides. --- crates/ecolor/src/color32.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ecolor/src/color32.rs b/crates/ecolor/src/color32.rs index b7022a91c34..9103a9737dd 100644 --- a/crates/ecolor/src/color32.rs +++ b/crates/ecolor/src/color32.rs @@ -104,7 +104,7 @@ impl Color32 { static LOOKUP_TABLE: Lazy<[u8; 256 * 256]> = Lazy::new(|| { use crate::{gamma_u8_from_linear_f32, linear_f32_from_gamma_u8}; core::array::from_fn(|i| { - let [value, alpha] = (i as u16).to_be_bytes(); + let [value, alpha] = (i as u16).to_ne_bytes(); let value_lin = linear_f32_from_gamma_u8(value); let alpha_lin = linear_f32_from_linear_u8(alpha); gamma_u8_from_linear_f32(value_lin * alpha_lin) @@ -112,7 +112,7 @@ impl Color32 { }); let [r, g, b] = [r, g, b] - .map(|value| LOOKUP_TABLE[usize::from(u16::from_be_bytes([value, a]))]); + .map(|value| LOOKUP_TABLE[usize::from(u16::from_ne_bytes([value, a]))]); Self::from_rgba_premultiplied(r, g, b, a) } }