From cc126254fdce063c2df544cf96e61cee58b107c1 Mon Sep 17 00:00:00 2001 From: Vladislav Richter Date: Mon, 8 Feb 2016 11:43:45 +0100 Subject: [PATCH] Update ByteExtensions.cs Original implementation didn't work for bit-length of 4 Former-commit-id: bc96d70df88c933fc10b815a9b08327bbdae5461 Former-commit-id: 2678a00b2afc86526cffd3bb68d6bb5be1652a92 Former-commit-id: d64de4730e2465cb9e89c1d7c673ca86d2893523 --- src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs b/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs index b72ce9d26c..e4657511af 100644 --- a/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs +++ b/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs @@ -32,7 +32,8 @@ namespace ImageProcessorCore { result = new byte[bytes.Length * 8 / bits]; - int factor = (int)Math.Pow(2, bits) - 1; + // BUGFIX I dont think it should be there, but I am not sure if it breaks something else + //int factor = (int)Math.Pow(2, bits) - 1; int mask = 0xFF >> (8 - bits); int resultOffset = 0; @@ -40,7 +41,7 @@ namespace ImageProcessorCore { for (int shift = 0; shift < 8; shift += bits) { - int colorIndex = ((b >> (8 - bits - shift)) & mask) * (255 / factor); + int colorIndex = ((b >> (8 - bits - shift)) & mask); // * (255 / factor); result[resultOffset] = (byte)colorIndex;