|
|
|
@ -131,6 +131,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore |
|
|
|
try |
|
|
|
{ |
|
|
|
int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette); |
|
|
|
ushort bitsPerPixel = this.infoHeader.BitsPerPixel; |
|
|
|
|
|
|
|
image = new Image<TPixel>(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); |
|
|
|
|
|
|
|
@ -138,23 +139,27 @@ internal sealed class BmpDecoderCore : ImageDecoderCore |
|
|
|
|
|
|
|
switch (this.infoHeader.Compression) |
|
|
|
{ |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is 32 && this.bmpMetadata.InfoHeaderType is BmpInfoHeaderType.WinVersion3: |
|
|
|
case BmpCompression.RGB when bitsPerPixel is 32 && this.bmpMetadata.InfoHeaderType is BmpInfoHeaderType.WinVersion3: |
|
|
|
this.ReadRgb32Slow(stream, pixels, this.infoHeader.Width, this.infoHeader.Height, inverted); |
|
|
|
|
|
|
|
break; |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is 32: |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is 32: |
|
|
|
this.ReadRgb32Fast(stream, pixels, this.infoHeader.Width, this.infoHeader.Height, inverted); |
|
|
|
|
|
|
|
break; |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is 24: |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is 24: |
|
|
|
this.ReadRgb24(stream, pixels, this.infoHeader.Width, this.infoHeader.Height, inverted); |
|
|
|
|
|
|
|
break; |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is 16: |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is 16: |
|
|
|
this.ReadRgb16(stream, pixels, this.infoHeader.Width, this.infoHeader.Height, inverted); |
|
|
|
|
|
|
|
break; |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is <= 8 && this.processedAlphaMask: |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is > 0 and <= 8 && this.processedAlphaMask: |
|
|
|
this.ReadRgbPaletteWithAlphaMask( |
|
|
|
stream, |
|
|
|
pixels, |
|
|
|
@ -166,7 +171,8 @@ internal sealed class BmpDecoderCore : ImageDecoderCore |
|
|
|
inverted); |
|
|
|
|
|
|
|
break; |
|
|
|
case BmpCompression.RGB when this.infoHeader.BitsPerPixel is <= 8: |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is > 0 and <= 8: |
|
|
|
this.ReadRgbPalette( |
|
|
|
stream, |
|
|
|
pixels, |
|
|
|
@ -179,6 +185,10 @@ internal sealed class BmpDecoderCore : ImageDecoderCore |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case BmpCompression.RGB when bitsPerPixel is <= 0 or > 32: |
|
|
|
BmpThrowHelper.ThrowInvalidImageContentException($"Invalid bits per pixel: {bitsPerPixel}"); |
|
|
|
break; |
|
|
|
|
|
|
|
case BmpCompression.RLE24: |
|
|
|
this.ReadRle24(stream, pixels, this.infoHeader.Width, this.infoHeader.Height, inverted); |
|
|
|
|
|
|
|
|