我想知道是否可以指示成像 PNG 编码器不要将任何伽玛和色度信息添加到 1 位 PNG。
我正在为图像创建 2 个调色板
ColorPalette* pal = (ColorPalette*)CoTaskMemAlloc(sizeof(ColorPalette) + 2 * sizeof(ARGB));
pal->Count = 2;
pal->Flags = 0;
pal->Entries[0] = MAKEARGB(0,0,0,0);
pal->Entries[1] = MAKEARGB(0,255,255,255);
if (FAILED(res = sink->SetPalette(pal))) {
return res;
}
CoTaskMemFree(pal);
然后就
BitmapData bmData;
bmData.Height = bm.bmHeight;
bmData.Width = bm.bmWidth;
bmData.Scan0 = bm.bmBits;
bmData.PixelFormat = PixelFormat1bppIndexed;
UINT bitsPerLine = imageInfo.Width * bm.bmBitsPixel;
UINT bitAlignment = sizeof(LONG) * 8;
UINT bitStride = bitAlignment * (bitsPerLine / bitAlignment); // The image buffer is always padded to LONG boundaries
if ((bitsPerLine % bitAlignment) != 0) bitStride += bitAlignment; // Add a bit more for the leftover values
bmData.Stride = bitStride / 8;
if (FAILED(res = sink->PushPixelData(&rect, &bmData, TRUE))) {
return res;
}
生成的 PNG 图像非常大,并且包含以下无用的标头:
sRGB、gAMA、cHRM
我实际上只期待 PLTE 而不是 sRGB。如何设置编码器以跳过伽玛和色度计算?