From e020ae54725ed474f4171ce18ff7281c4c19a09b 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: c3a980b4d7208cde0f3bef9dd5c2cc28ef79e68b Former-commit-id: 645e1ebe51f96d97ff81e9962ffd0cb809b5d8a4 Former-commit-id: 16448059bf75d00199580eab8d53f985adec178d --- 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);