@@ -14,8 +14,8 @@ impl Image {
14
14
let format: TextureFormat ;
15
15
16
16
match dyn_img {
17
- DynamicImage :: ImageLuma8 ( i ) => {
18
- let i = DynamicImage :: ImageLuma8 ( i ) . into_rgba8 ( ) ;
17
+ DynamicImage :: ImageLuma8 ( image ) => {
18
+ let i = DynamicImage :: ImageLuma8 ( image ) . into_rgba8 ( ) ;
19
19
width = i. width ( ) ;
20
20
height = i. height ( ) ;
21
21
format = if is_srgb {
@@ -26,8 +26,8 @@ impl Image {
26
26
27
27
data = i. into_raw ( ) ;
28
28
}
29
- DynamicImage :: ImageLumaA8 ( i ) => {
30
- let i = DynamicImage :: ImageLumaA8 ( i ) . into_rgba8 ( ) ;
29
+ DynamicImage :: ImageLumaA8 ( image ) => {
30
+ let i = DynamicImage :: ImageLumaA8 ( image ) . into_rgba8 ( ) ;
31
31
width = i. width ( ) ;
32
32
height = i. height ( ) ;
33
33
format = if is_srgb {
@@ -38,8 +38,8 @@ impl Image {
38
38
39
39
data = i. into_raw ( ) ;
40
40
}
41
- DynamicImage :: ImageRgb8 ( i ) => {
42
- let i = DynamicImage :: ImageRgb8 ( i ) . into_rgba8 ( ) ;
41
+ DynamicImage :: ImageRgb8 ( image ) => {
42
+ let i = DynamicImage :: ImageRgb8 ( image ) . into_rgba8 ( ) ;
43
43
width = i. width ( ) ;
44
44
height = i. height ( ) ;
45
45
format = if is_srgb {
@@ -50,68 +50,54 @@ impl Image {
50
50
51
51
data = i. into_raw ( ) ;
52
52
}
53
- DynamicImage :: ImageRgba8 ( i ) => {
54
- width = i . width ( ) ;
55
- height = i . height ( ) ;
53
+ DynamicImage :: ImageRgba8 ( image ) => {
54
+ width = image . width ( ) ;
55
+ height = image . height ( ) ;
56
56
format = if is_srgb {
57
57
TextureFormat :: Rgba8UnormSrgb
58
58
} else {
59
59
TextureFormat :: Rgba8Unorm
60
60
} ;
61
61
62
- data = i . into_raw ( ) ;
62
+ data = image . into_raw ( ) ;
63
63
}
64
- DynamicImage :: ImageLuma16 ( i ) => {
65
- width = i . width ( ) ;
66
- height = i . height ( ) ;
64
+ DynamicImage :: ImageLuma16 ( image ) => {
65
+ width = image . width ( ) ;
66
+ height = image . height ( ) ;
67
67
format = TextureFormat :: R16Uint ;
68
68
69
- let raw_data = i . into_raw ( ) ;
69
+ let raw_data = image . into_raw ( ) ;
70
70
71
71
data = cast_slice ( & raw_data) . to_owned ( ) ;
72
72
}
73
- DynamicImage :: ImageLumaA16 ( i ) => {
74
- width = i . width ( ) ;
75
- height = i . height ( ) ;
73
+ DynamicImage :: ImageLumaA16 ( image ) => {
74
+ width = image . width ( ) ;
75
+ height = image . height ( ) ;
76
76
format = TextureFormat :: Rg16Uint ;
77
77
78
- let raw_data = i . into_raw ( ) ;
78
+ let raw_data = image . into_raw ( ) ;
79
79
80
80
data = cast_slice ( & raw_data) . to_owned ( ) ;
81
81
}
82
82
DynamicImage :: ImageRgb16 ( image) => {
83
- width = image. width ( ) ;
84
- height = image. height ( ) ;
85
- format = TextureFormat :: Rgba16Uint ;
86
-
87
- let mut local_data =
88
- Vec :: with_capacity ( width as usize * height as usize * format. pixel_size ( ) ) ;
89
-
90
- for pixel in image. into_raw ( ) . chunks_exact ( 3 ) {
91
- // TODO: use the array_chunks method once stabilised
92
- // https://github.com/rust-lang/rust/issues/74985
93
- let r = pixel[ 0 ] ;
94
- let g = pixel[ 1 ] ;
95
- let b = pixel[ 2 ] ;
96
- let a = u16:: max_value ( ) ;
97
-
98
- local_data. extend_from_slice ( & r. to_ne_bytes ( ) ) ;
99
- local_data. extend_from_slice ( & g. to_ne_bytes ( ) ) ;
100
- local_data. extend_from_slice ( & b. to_ne_bytes ( ) ) ;
101
- local_data. extend_from_slice ( & a. to_ne_bytes ( ) ) ;
102
- }
103
-
104
- data = local_data;
105
- }
106
- DynamicImage :: ImageRgba16 ( i) => {
83
+ let i = DynamicImage :: ImageRgb16 ( image) . into_rgba16 ( ) ;
107
84
width = i. width ( ) ;
108
85
height = i. height ( ) ;
109
- format = TextureFormat :: Rgba16Uint ;
86
+ format = TextureFormat :: Rgba16Unorm ;
110
87
111
88
let raw_data = i. into_raw ( ) ;
112
89
113
90
data = cast_slice ( & raw_data) . to_owned ( ) ;
114
91
}
92
+ DynamicImage :: ImageRgba16 ( image) => {
93
+ width = image. width ( ) ;
94
+ height = image. height ( ) ;
95
+ format = TextureFormat :: Rgba16Unorm ;
96
+
97
+ let raw_data = image. into_raw ( ) ;
98
+
99
+ data = cast_slice ( & raw_data) . to_owned ( ) ;
100
+ }
115
101
DynamicImage :: ImageRgb32F ( image) => {
116
102
width = image. width ( ) ;
117
103
height = image. height ( ) ;
0 commit comments