File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,14 @@ impl ChannelMasks {
201201 blue : 0x0000FF ,
202202 alpha : 0 ,
203203 } ;
204+
205+ /// Argb888 color masks.
206+ pub const ARGB888 : Self = Self {
207+ red : 0xFF000000 ,
208+ green : 0xFF0000 ,
209+ blue : 0xFF00 ,
210+ alpha : 0xFF ,
211+ } ;
204212}
205213
206214/// Describes how the BMP file is compressed.
Original file line number Diff line number Diff line change 5656 ColorType :: Rgb555 => Rgb555 :: from ( RawU16 :: from_u32 ( color) ) . into ( ) ,
5757 ColorType :: Rgb565 => Rgb565 :: from ( RawU16 :: from_u32 ( color) ) . into ( ) ,
5858 ColorType :: Rgb888 | ColorType :: Xrgb8888 => Rgb888 :: from ( RawU24 :: from_u32 ( color) ) . into ( ) ,
59+ ColorType :: Argb8888 => Rgb888 :: from ( RawU24 :: from_u32 ( color >> 8 ) ) . into ( ) ,
5960 } ;
6061
6162 Some ( Pixel ( position, color) )
Original file line number Diff line number Diff line change @@ -362,6 +362,11 @@ where
362362 RawColors :: < RawU32 > :: new ( & self . raw_bmp )
363363 . map ( |raw| Rgb888 :: from ( RawU24 :: new ( raw. into_inner ( ) ) ) . into ( ) ) ,
364364 ) ,
365+ ColorType :: Argb8888 => target. fill_contiguous (
366+ & area,
367+ RawColors :: < RawU32 > :: new ( & self . raw_bmp )
368+ . map ( |raw| Rgb888 :: from ( RawU24 :: new ( raw. into_inner ( ) >> 8 ) ) . into ( ) ) ,
369+ ) ,
365370 }
366371 }
367372
@@ -421,6 +426,10 @@ where
421426 . raw_bmp
422427 . pixel ( p)
423428 . map ( |raw| Rgb888 :: from ( RawU24 :: from_u32 ( raw) ) . into ( ) ) ,
429+ ColorType :: Argb8888 => self
430+ . raw_bmp
431+ . pixel ( p)
432+ . map ( |raw| Rgb888 :: from ( RawU24 :: from_u32 ( raw >> 8 ) ) . into ( ) ) ,
424433 }
425434 }
426435}
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ pub enum ColorType {
157157 Rgb565 ,
158158 Rgb888 ,
159159 Xrgb8888 ,
160+ Argb8888 ,
160161}
161162
162163impl ColorType {
@@ -184,6 +185,8 @@ impl ColorType {
184185 if let Some ( masks) = header. channel_masks {
185186 if masks == ChannelMasks :: RGB888 {
186187 ColorType :: Xrgb8888
188+ } else if masks == ChannelMasks :: ARGB888 {
189+ ColorType :: Argb8888
187190 } else {
188191 return Err ( ParseError :: UnsupportedChannelMasks ) ;
189192 }
You can’t perform that action at this time.
0 commit comments