File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -108,15 +108,17 @@ impl Color32 {
108
108
// common-case optimization
109
109
255 => Self :: from_rgb ( r, g, b) ,
110
110
a => {
111
- static LOOKUP_TABLE : OnceLock < [ u8 ; 256 * 256 ] > = OnceLock :: new ( ) ;
111
+ static LOOKUP_TABLE : OnceLock < Box < [ u8 ] > > = OnceLock :: new ( ) ;
112
112
let lut = LOOKUP_TABLE . get_or_init ( || {
113
113
use crate :: { gamma_u8_from_linear_f32, linear_f32_from_gamma_u8} ;
114
- core:: array:: from_fn ( |i| {
115
- let [ value, alpha] = ( i as u16 ) . to_ne_bytes ( ) ;
116
- let value_lin = linear_f32_from_gamma_u8 ( value) ;
117
- let alpha_lin = linear_f32_from_linear_u8 ( alpha) ;
118
- gamma_u8_from_linear_f32 ( value_lin * alpha_lin)
119
- } )
114
+ ( 0 ..=u16:: MAX )
115
+ . map ( |i| {
116
+ let [ value, alpha] = i. to_ne_bytes ( ) ;
117
+ let value_lin = linear_f32_from_gamma_u8 ( value) ;
118
+ let alpha_lin = linear_f32_from_linear_u8 ( alpha) ;
119
+ gamma_u8_from_linear_f32 ( value_lin * alpha_lin)
120
+ } )
121
+ . collect ( )
120
122
} ) ;
121
123
122
124
let [ r, g, b] =
You can’t perform that action at this time.
0 commit comments