Skip to content

Resized 32-bit BI_RGB BMP is completely black #732

@frofflehop

Description

@frofflehop

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

The file "Test-original.bmp" is loaded, resized to half width and height, and then saved as "Test-resized.bmp". The resulting image is the correct size, but every pixel is black.

"Test-original.bmp" is a 32-bit BI_RGB image where the alpha channel for each pixel is 0. According to MSDN, the alpha channel byte is not used, so I don't think it should be interpreted during the resize if that's what's causing resulting image to be black.

https://msdn.microsoft.com/en-us/library/dd183376%28VS.85%29.aspx
"The value for blue is in the least significant 8 bits, followed by 8 bits each for green and red. The high byte in each DWORD is not used"

Steps to Reproduce

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.IO;

namespace TestImageSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Image<Rgba32> image = Image.Load("Test-original.bmp");
            image.Mutate(img => img.Resize(image.Width / 2, image.Height / 2));
            using (FileStream output = File.OpenWrite("Test-resized.bmp"))
            {
                image.SaveAsBmp(output);
            }
        }
    }
}

Test images attached:
TestImages.zip

System Configuration

  • ImageSharp version:
    -- SixLabors.ImageSharp.1.0.0-beta0005
  • Other ImageSharp packages and versions:
    -- SixLabors.Core.1.0.0-beta0006
    -- SixLabors.Fonts.1.0.0-beta0007
    -- SixLabors.ImageSharp.Drawing.1.0.0-beta0005
    -- SixLabors.Shapes.1.0.0-beta0007
  • Environment (Operating system, version and so on):
    -- Windows 10 Pro 64-bit x64
    -- Microsoft Visual Studio Community 2017 Preview Version 15.9.0 Preview 3.0
  • .NET Framework version:
    -- 4.6.1
  • Additional information:
    -- None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions