File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,21 @@ private static ImageSource DecodeWithPfim(Stream stream, long size)
117117 case ImageFormat . Rgb24 :
118118 pixelFormat = PixelFormats . Bgr24 ;
119119 break ;
120+ case ImageFormat . Rgba16 :
121+ var pixels2 = pfiImage . DataLen / 2 ;
122+ data = new byte [ pixels2 * 4 ] ;
123+ stride = pfiImage . Width * 4 ;
124+ for ( var i = 0 ; i < pixels2 ; i ++ )
125+ {
126+ var src = BitConverter . ToUInt16 ( pfiImage . Data , i * 2 ) ;
127+ data [ i * 4 + 0 ] = ( byte ) Math . Round ( ( src & 0x0F ) / 15F * 255 ) ; // B
128+ data [ i * 4 + 1 ] = ( byte ) Math . Round ( ( ( src >> 4 ) & 0x0F ) / 15F * 255 ) ; // G
129+ data [ i * 4 + 2 ] = ( byte ) Math . Round ( ( ( src >> 8 ) & 0x0F ) / 15F * 255 ) ; // R
130+ data [ i * 4 + 3 ] = ( byte ) Math . Round ( ( ( src >> 12 ) & 0x0F ) / 15F * 255 ) ; // A
131+ }
132+
133+ alphaFormat = AlphaFormat . Premul ;
134+ break ;
120135 case ImageFormat . Rgba32 :
121136 alphaFormat = AlphaFormat . Premul ;
122137 break ;
@@ -131,7 +146,7 @@ private static ImageSource DecodeWithPfim(Stream stream, long size)
131146 return new ImageSource ( bitmap , size ) ;
132147 }
133148 }
134- catch ( Exception e )
149+ catch
135150 {
136151 return new ImageSource ( null , 0 ) ;
137152 }
You can’t perform that action at this time.
0 commit comments