Are you sure about this? My understanding is that the result of CopyPalette is unspecified when your pixel format is not an indexed color format (in this case, a grayscale format).
So, while it's not really a problem to do that (unless a program relies on the exact behavior of this decoder, which seems unlikely), for correctness you shouldn't ever be relying on this change.
Vincent Povirk madewokherd@gmail.com wrote:
Are you sure about this? My understanding is that the result of CopyPalette is unspecified when your pixel format is not an indexed color format (in this case, a grayscale format).
It seems that WIC always creates a predefined palette if an image doesn't have one, see the test sent in 2/5.
So, while it's not really a problem to do that (unless a program relies on the exact behavior of this decoder, which seems unlikely), for correctness you shouldn't ever be relying on this change.
The problem is that gdiplus always expects a palette when converting between formats and crashes if there is no one.
Are you sure about this? My understanding is that the result of CopyPalette is unspecified when your pixel format is not an indexed color format (in this case, a grayscale format).
It seems that WIC always creates a predefined palette if an image doesn't have one, see the test sent in 2/5.
The test in 2/5 was for gdiplus, not WIC.
So, while it's not really a problem to do that (unless a program relies on the exact behavior of this decoder, which seems unlikely), for correctness you shouldn't ever be relying on this change.
The problem is that gdiplus always expects a palette when converting between formats and crashes if there is no one.
Gdiplus can create its own grayscale palette for grayscale formats if it needs one.
Vincent Povirk madewokherd@gmail.com wrote:
Are you sure about this? My understanding is that the result of CopyPalette is unspecified when your pixel format is not an indexed color format (in this case, a grayscale format).
It seems that WIC always creates a predefined palette if an image doesn't have one, see the test sent in 2/5.
The test in 2/5 was for gdiplus, not WIC.
My understanding is that gdiplus just reports what WIC returns in that regard, and gdiplus doesn't generate fake palettes for real images (read: loaded from a stream or a file).
So, while it's not really a problem to do that (unless a program relies on the exact behavior of this decoder, which seems unlikely), for correctness you shouldn't ever be relying on this change.
The problem is that gdiplus always expects a palette when converting between formats and crashes if there is no one.
Gdiplus can create its own grayscale palette for grayscale formats if it needs one.
Yes, but it should do that only for broken cases, when palette is not provided with source data, like converting from indexed BitmapData in GdipBitmapUnlockBits, or for idexed formats passed to GdipCreateBitmapFromScan0.
The test in 2/5 was for gdiplus, not WIC.
My understanding is that gdiplus just reports what WIC returns in that regard, and gdiplus doesn't generate fake palettes for real images (read: loaded from a stream or a file).
WIC did report a grayscale palette, implicitly in the pixel format. It doesn't need an explicit palette because it's not reporting an indexed color format.
Yes, but it should do that only for broken cases, when palette is not provided with source data, like converting from indexed BitmapData in GdipBitmapUnlockBits, or for idexed formats passed to GdipCreateBitmapFromScan0.
I see no reason why gdiplus can't or shouldn't add a palette when converting from a WIC source with a grayscale image format to a gdiplus bitmap. If the resulting bitmap is indexed color, it probably should.
Vincent Povirk madewokherd@gmail.com wrote:
The test in 2/5 was for gdiplus, not WIC.
My understanding is that gdiplus just reports what WIC returns in that regard, and gdiplus doesn't generate fake palettes for real images (read: loaded from a stream or a file).
WIC did report a grayscale palette, implicitly in the pixel format. It doesn't need an explicit palette because it's not reporting an indexed color format.
A palette for 1 bpp format is optional.
Yes, but it should do that only for broken cases, when palette is not provided with source data, like converting from indexed BitmapData in GdipBitmapUnlockBits, or for idexed formats passed to GdipCreateBitmapFromScan0.
I see no reason why gdiplus can't or shouldn't add a palette when converting from a WIC source with a grayscale image format to a gdiplus bitmap. If the resulting bitmap is indexed color, it probably should.
I think that's a job of WIC when it saves pixel data, gdiplus should create a fake palette only for internal conversions, but even that job should be done by a WIC pixel format converter.