From ff770c1b34214fe95da99c5530f586a38f0fed6d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 20 Jan 2016 16:48:48 +1100 Subject: [PATCH] Minor bitmap optimizations Former-commit-id: b82f0fb8a821c2be2f24f602076938999a99c98f Former-commit-id: c3771878dc9096ee355c170129765ec6b0f488f2 Former-commit-id: 49cc7337fcab45f5957dfea0b650f6244f57f0fa --- src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs b/src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs index c11f2d7c7..4aa099a32 100644 --- a/src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs @@ -87,7 +87,8 @@ namespace ImageProcessor.Formats if (colorMapSize > 0) { - if (colorMapSize > 255 * 4) + // 255 * 4 + if (colorMapSize > 1020) { throw new ImageFormatException($"Invalid bmp colormap size '{colorMapSize}'"); } @@ -242,8 +243,8 @@ namespace ImageProcessor.Formats private void ReadRgb16(float[] imageData, int width, int height) { // We divide here as we will store the colors in our floating point format. - const int ScaleR = (256 / 32) / 32; - const int ScaleG = (256 / 64) / 64; + const float ScaleR = 0.25F; // (256 / 32) / 32 + const float ScaleG = 0.0625F; // (256 / 64) / 64 int alignment; byte[] data = this.GetImageArray(width, height, 2, out alignment);