This fix Naruto Shippuden games crash at start.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/windowscodecs/converter.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 6e7bb8e781..2444e3f3e6 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -55,6 +55,7 @@ enum pixelformat { format_32bppBGR, format_32bppBGRA, format_32bppPBGRA, + format_32bppRGBA, format_48bppRGB, format_64bppRGBA, format_32bppCMYK, @@ -907,6 +908,35 @@ static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICR } }
+static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + HRESULT hr; + + switch (source_format) + { + case format_32bppRGBA: + if (prc) + return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + return S_OK; + default: + hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); + if (SUCCEEDED(hr) && prc) + { + INT x, y; + + for (y=0; y<prc->Height; y++) + for (x=0; x<prc->Width; x++) + { + BYTE b = pbBuffer[cbStride*y+4*x]; + pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x+2]; + pbBuffer[cbStride*y+4*x+2] = b; + } + } + return hr; + } +} + static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) { @@ -1237,6 +1267,7 @@ static const struct pixelformatinfo supported_formats[] = { {format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat}, {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR}, {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA}, + {format_32bppRGBA, &GUID_WICPixelFormat32bppRGBA, copypixels_to_32bppRGBA}, {format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA}, {format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL}, {format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL},