Browse Source

Minor bitmap optimizations

Former-commit-id: b82f0fb8a821c2be2f24f602076938999a99c98f
Former-commit-id: c3771878dc9096ee355c170129765ec6b0f488f2
Former-commit-id: 49cc7337fcab45f5957dfea0b650f6244f57f0fa
af/merge-core
James Jackson-South 10 years ago
parent
commit
ff770c1b34
  1. 7
      src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs

7
src/ImageProcessor/Formats/Bmp/BmpDecoderCore.cs

@ -87,7 +87,8 @@ namespace ImageProcessor.Formats
if (colorMapSize > 0) if (colorMapSize > 0)
{ {
if (colorMapSize > 255 * 4) // 255 * 4
if (colorMapSize > 1020)
{ {
throw new ImageFormatException($"Invalid bmp colormap size '{colorMapSize}'"); throw new ImageFormatException($"Invalid bmp colormap size '{colorMapSize}'");
} }
@ -242,8 +243,8 @@ namespace ImageProcessor.Formats
private void ReadRgb16(float[] imageData, int width, int height) private void ReadRgb16(float[] imageData, int width, int height)
{ {
// We divide here as we will store the colors in our floating point format. // We divide here as we will store the colors in our floating point format.
const int ScaleR = (256 / 32) / 32; const float ScaleR = 0.25F; // (256 / 32) / 32
const int ScaleG = (256 / 64) / 64; const float ScaleG = 0.0625F; // (256 / 64) / 64
int alignment; int alignment;
byte[] data = this.GetImageArray(width, height, 2, out alignment); byte[] data = this.GetImageArray(width, height, 2, out alignment);

Loading…
Cancel
Save