Skip to content

Commit 30eb861

Browse files
Paul Gofmanivyl
authored andcommitted
windowscodecs: Implement 48bppRGB -> 64bppRGBA conversion.
CW-Bug-Id: #24367
1 parent f38cf7e commit 30eb861

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

dlls/windowscodecs/converter.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,66 @@ static HRESULT copypixels_to_16bppBGRA5551(struct FormatConverter *This, const W
15551555
}
15561556
}
15571557

1558+
static HRESULT copypixels_to_64bppRGBA(struct FormatConverter *This, const WICRect *prc,
1559+
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1560+
{
1561+
HRESULT hr;
1562+
1563+
switch (source_format)
1564+
{
1565+
case format_64bppRGBA:
1566+
if (prc)
1567+
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1568+
return S_OK;
1569+
1570+
case format_48bppRGB:
1571+
{
1572+
UINT srcstride, srcdatasize;
1573+
const USHORT *srcpixel;
1574+
const BYTE *srcrow;
1575+
USHORT *dstpixel;
1576+
BYTE *srcdata;
1577+
BYTE *dstrow;
1578+
INT x, y;
1579+
1580+
if (!prc)
1581+
return S_OK;
1582+
1583+
srcstride = 6 * prc->Width;
1584+
srcdatasize = srcstride * prc->Height;
1585+
1586+
srcdata = malloc(srcdatasize);
1587+
if (!srcdata) return E_OUTOFMEMORY;
1588+
1589+
hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1590+
if (SUCCEEDED(hr))
1591+
{
1592+
srcrow = srcdata;
1593+
dstrow = pbBuffer;
1594+
for (y = 0; y < prc->Height; y++)
1595+
{
1596+
srcpixel = (USHORT *)srcrow;
1597+
dstpixel= (USHORT *)dstrow;
1598+
for (x = 0; x < prc->Width; x++)
1599+
{
1600+
*dstpixel++ = *srcpixel++;
1601+
*dstpixel++ = *srcpixel++;
1602+
*dstpixel++ = *srcpixel++;
1603+
*dstpixel++ = 65535;
1604+
}
1605+
srcrow += srcstride;
1606+
dstrow += cbStride;
1607+
}
1608+
}
1609+
free(srcdata);
1610+
return hr;
1611+
}
1612+
default:
1613+
FIXME("Unimplemented conversion path %d.\n", source_format);
1614+
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
1615+
}
1616+
}
1617+
15581618
static const struct pixelformatinfo supported_formats[] = {
15591619
{format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL, TRUE},
15601620
{format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL, TRUE},
@@ -1578,7 +1638,7 @@ static const struct pixelformatinfo supported_formats[] = {
15781638
{format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA},
15791639
{format_32bppPRGBA, &GUID_WICPixelFormat32bppPRGBA, copypixels_to_32bppPRGBA},
15801640
{format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
1581-
{format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL},
1641+
{format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, copypixels_to_64bppRGBA},
15821642
{format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL},
15831643
{0}
15841644
};

dlls/windowscodecs/tests/converter.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,20 @@ static const WORD bits_16bppBGRA5551[] = {
622622
static const struct bitmap_data testdata_16bppBGRA5551 = {
623623
&GUID_WICPixelFormat16bppBGRA5551, 16, (BYTE*)bits_16bppBGRA5551, 32, 2, 96.0, 96.0};
624624

625+
static const WORD bits_48bppRGB[] = {
626+
0,0,0, 0,65535,0, 32767,32768,32767,
627+
65535,65535,65535, 10,10,10, 0,0,10};
628+
629+
static const struct bitmap_data testdata_48bppRGB = {
630+
&GUID_WICPixelFormat48bppRGB, 48, (BYTE*)bits_48bppRGB, 3, 2, 96.0, 96.0};
631+
632+
static const WORD bits_64bppRGBA_2[] = {
633+
0,0,0,65535, 0,65535,0,65535, 32767,32768,32767,65535,
634+
65535,65535,65535,65535, 10,10,10,65535, 0,0,10,65535,};
635+
636+
static const struct bitmap_data testdata_64bppRGBA_2 = {
637+
&GUID_WICPixelFormat64bppRGBA, 64, (BYTE*)bits_64bppRGBA_2, 3, 2, 96.0, 96.0};
638+
625639
static void test_conversion(const struct bitmap_data *src, const struct bitmap_data *dst, const char *name, BOOL todo)
626640
{
627641
BitmapTestSrc *src_obj;
@@ -2075,6 +2089,7 @@ START_TEST(converter)
20752089
test_conversion(&testdata_32bppGrayFloat, &testdata_24bppBGR_gray, "32bppGrayFloat -> 24bppBGR gray", FALSE);
20762090
test_conversion(&testdata_32bppGrayFloat, &testdata_8bppGray, "32bppGrayFloat -> 8bppGray", FALSE);
20772091
test_conversion(&testdata_32bppBGRA, &testdata_16bppBGRA5551, "32bppBGRA -> 16bppBGRA5551", FALSE);
2092+
test_conversion(&testdata_48bppRGB, &testdata_64bppRGBA_2, "48bppRGB -> 64bppRGBA", FALSE);
20782093

20792094
test_invalid_conversion();
20802095
test_default_converter();

0 commit comments

Comments
 (0)