You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
When simply opening and saving the image below all transparency is removed.
Input:
Output:
Steps to Reproduce
The following code reproduces the problem:
using (var img = Image.Load(image1path))
{
using (var fs = new FileStream(outputImage, FileMode.Create))
{
img.SaveAsPng(fs);
}
}
Investigation into issue
To help you guys out a bit I did some investigation myself to see where the issue comes from. First of all I did see that my image was detected as an Rgb image but it still had a transparent title bar in it.
PNG Analyzer shows a Transparency header though:
Doing some debugging I finally found out what was causing the problem. When the image is loaded a bool: 'hasTrans' is set to true and the transparent color is set to 211, 211, 211. This basically means that everywhere in the image where the color 211, 211, 211 is used it will be rendered as transparent.
However the issue occurs when we save the image again. The hasTrans flag is not taken into account when saving the image and thus it will simply be stored as Rgb without any data about transparency.
Possible resolutions
As far as I can think of right now there's 2 possible resolutions:
Store transparency data on the image metadata and use this when writing the image again
If the data of an Rgb image contains a transparency value set to 0, save the image as Rgba32
I guess that both solution still have quite a bit of work to do though.
System Configuration
ImageSharp version: Github version as of 31-10-2018 and also Myget 1.0.0-dev002131
Other ImageSharp packages and versions:
Environment (Operating system, version and so on): Win10
.NET Framework version: .NET Core 2.1
Additional information:
The text was updated successfully, but these errors were encountered:
Prerequisites
DEBUG
andRELEASE
modeDescription
When simply opening and saving the image below all transparency is removed.
Input:
Output:
Steps to Reproduce
The following code reproduces the problem:
Investigation into issue
To help you guys out a bit I did some investigation myself to see where the issue comes from. First of all I did see that my image was detected as an Rgb image but it still had a transparent title bar in it.
PNG Analyzer shows a Transparency header though:
Doing some debugging I finally found out what was causing the problem. When the image is loaded a bool: 'hasTrans' is set to true and the transparent color is set to 211, 211, 211. This basically means that everywhere in the image where the color 211, 211, 211 is used it will be rendered as transparent.
However the issue occurs when we save the image again. The hasTrans flag is not taken into account when saving the image and thus it will simply be stored as Rgb without any data about transparency.
Possible resolutions
As far as I can think of right now there's 2 possible resolutions:
I guess that both solution still have quite a bit of work to do though.
System Configuration
The text was updated successfully, but these errors were encountered: