New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Drawing.Imaging.ImageAttributes.SetColorKey() is set but not applied. #8806
Comments
From https://msdn.microsoft.com/en-us/library/windows/desktop/ms535429(v=vs.85).aspx sample code: Ignoring the possibility i may be doing this C++ incorrectly, it looks as though this is a bug in GDI+. int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
ImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if (size == 0)
return -1; // Failure
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if (pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for (UINT j = 0; j < num; ++j)
{
if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
static void test_imageAttributes() {
Image image{L"C:\\Users\\hugh\\Documents\\Visual Studio 2017\\Projects\\ConsoleApplication1\\ConsoleApplication1\\173x183_indexed_8bit.bmp"};
Graphics graphics((HWND)0);
ImageAttributes imAtt;
imAtt.SetColorKey(
Color(0, 0, 0),
Color(255, 255, 255),
ColorAdjustTypeBitmap);
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);
graphics.DrawImage(
&image,
Rect(20, 20, image.GetWidth(), image.GetHeight()), // dest rect
0, 0, image.GetWidth(), image.GetHeight(), // source rect
UnitPixel,
&imAtt);
image.Save(L"C:\\Users\\hugh\\Desktop\\stuff.png", &pngClsid);
} In the sample code above, modified from the sample online, it shows that the C++ implementation looks broken. If this is indeed a GDI+ bug, I'm really not sure there's much we can do here. I think we should definitely keep the test, but maybe disable it. |
As this appears to be a GDI+ issue there isn't much we can do here. |
I am writing test for
System.Drawing.Imaging.ImageAttributes
dotnet/runtime#22130:Expected: Color.FromArgb(0, 0, 0, 0)
Actual: Color.FromArgb(255, 100, 100, 100)
I am running the test on
netfx
andnetcoreapp
and it fails on both.Looks like transparency isn't get applied.
[EDIT] Fixed code formatting - @karelz
The text was updated successfully, but these errors were encountered: