Skip to content

Commit cdcc830

Browse files
authored
Merge pull request #2793 from RunDevelopment/ext-color-L32
Add L32F and La32F to `ExtendedColorType`
2 parents 979a13f + b773c9d commit cdcc830

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/color.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ pub enum ExtendedColorType {
150150
Bgra8,
151151

152152
// TODO f16 types?
153+
/// Pixel is 32-bit float luminance
154+
L32F,
155+
/// Pixel is 32-bit float luminance with an alpha channel
156+
La32F,
153157
/// Pixel is 32-bit float RGB
154158
Rgb32F,
155159
/// Pixel is 32-bit float RGBA
@@ -180,12 +184,14 @@ impl ExtendedColorType {
180184
| ExtendedColorType::L4
181185
| ExtendedColorType::L8
182186
| ExtendedColorType::L16
187+
| ExtendedColorType::L32F
183188
| ExtendedColorType::Unknown(_) => 1,
184189
ExtendedColorType::La1
185190
| ExtendedColorType::La2
186191
| ExtendedColorType::La4
187192
| ExtendedColorType::La8
188-
| ExtendedColorType::La16 => 2,
193+
| ExtendedColorType::La16
194+
| ExtendedColorType::La32F => 2,
189195
ExtendedColorType::Rgb1
190196
| ExtendedColorType::Rgb2
191197
| ExtendedColorType::Rgb4
@@ -232,6 +238,8 @@ impl ExtendedColorType {
232238
ExtendedColorType::La16 => 32,
233239
ExtendedColorType::Rgb16 => 48,
234240
ExtendedColorType::Rgba16 => 64,
241+
ExtendedColorType::L32F => 32,
242+
ExtendedColorType::La32F => 64,
235243
ExtendedColorType::Rgb32F => 96,
236244
ExtendedColorType::Rgba32F => 128,
237245
ExtendedColorType::Bgr8 => 24,

‎src/traits.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,19 @@ impl PixelWithColorType for Luma<u8> {
224224
impl PixelWithColorType for Luma<u16> {
225225
const COLOR_TYPE: ExtendedColorType = ExtendedColorType::L16;
226226
}
227+
impl PixelWithColorType for Luma<f32> {
228+
const COLOR_TYPE: ExtendedColorType = ExtendedColorType::L32F;
229+
}
230+
227231
impl PixelWithColorType for LumaA<u8> {
228232
const COLOR_TYPE: ExtendedColorType = ExtendedColorType::La8;
229233
}
230234
impl PixelWithColorType for LumaA<u16> {
231235
const COLOR_TYPE: ExtendedColorType = ExtendedColorType::La16;
232236
}
237+
impl PixelWithColorType for LumaA<f32> {
238+
const COLOR_TYPE: ExtendedColorType = ExtendedColorType::La32F;
239+
}
233240

234241
/// Prevents down-stream users from implementing the `Primitive` trait
235242
pub(crate) mod private {

0 commit comments

Comments
 (0)