windowscodecs: Fix *_CopyPixels functions to properly handle a NULL rectangle.

This commit is contained in:
Krzysztof Nowicki 2010-10-19 18:50:36 +02:00 committed by Alexandre Julliard
parent f8e4a0f3b9
commit 145bda5aa6
6 changed files with 88 additions and 7 deletions

View File

@ -850,11 +850,27 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface,
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
{
FormatConverter *This = (FormatConverter*)iface;
WICRect rc;
HRESULT hr;
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
if (This->source)
{
if (!prc)
{
UINT width, height;
hr = IWICBitmapSource_GetSize(This->source, &width, &height);
if (FAILED(hr)) return hr;
rc.X = 0;
rc.Y = 0;
rc.Width = width;
rc.Height = height;
prc = &rc;
}
return This->dst_format->copy_function(This, prc, cbStride, cbBufferSize,
pbBuffer, This->src_format->format);
}
else
return WINCODEC_ERR_NOTINITIALIZED;
}

View File

@ -140,6 +140,7 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface,
UINT y;
UINT srcy, srcwidth, srcheight;
WICRect rc;
WICRect rect;
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
@ -155,6 +156,18 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface,
hr = IWICBitmapSource_GetSize(This->source, &srcwidth, &srcheight);
if (FAILED(hr)) return hr;
if (!prc)
{
UINT width, height;
hr = IWICBitmapSource_GetSize(iface, &width, &height);
if (FAILED(hr)) return hr;
rect.X = 0;
rect.Y = 0;
rect.Width = width;
rect.Height = height;
prc = ▭
}
for (y=prc->Y; y - prc->Y < prc->Height; y++)
{
if (This->flip_y)

View File

@ -184,9 +184,21 @@ static HRESULT copy_interlaced_pixels(const BYTE *srcbuffer,
const BYTE *src;
BYTE *dst;
UINT y;
WICRect rect;
if (rc->X < 0 || rc->Y < 0 || rc->X+rc->Width > srcwidth || rc->Y+rc->Height > srcheight)
return E_INVALIDARG;
if (!rc)
{
rect.X = 0;
rect.Y = 0;
rect.Width = srcwidth;
rect.Height = srcheight;
rc = &rect;
}
else
{
if (rc->X < 0 || rc->Y < 0 || rc->X+rc->Width > srcwidth || rc->Y+rc->Height > srcheight)
return E_INVALIDARG;
}
if (dststride < rc->Width)
return E_INVALIDARG;

View File

@ -519,8 +519,24 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
UINT data_size;
UINT max_row_needed;
jmp_buf jmpbuf;
WICRect rect;
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
if (!prc)
{
rect.X = 0;
rect.Y = 0;
rect.Width = This->cinfo.output_width;
rect.Height = This->cinfo.output_height;
prc = &rect;
}
else
{
if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->cinfo.output_width ||
prc->Y+prc->Height > This->cinfo.output_height)
return E_INVALIDARG;
}
if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8;
else if (This->cinfo.out_color_space == JCS_CMYK) bpp = 32;
else bpp = 24;

View File

@ -53,9 +53,21 @@ HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
{
UINT bytesperrow;
UINT row_offset; /* number of bits into the source rows where the data starts */
WICRect rect;
if (rc->X < 0 || rc->Y < 0 || rc->X+rc->Width > srcwidth || rc->Y+rc->Height > srcheight)
return E_INVALIDARG;
if (!rc)
{
rect.X = 0;
rect.Y = 0;
rect.Width = srcwidth;
rect.Height = srcheight;
rc = &rect;
}
else
{
if (rc->X < 0 || rc->Y < 0 || rc->X+rc->Width > srcwidth || rc->Y+rc->Height > srcheight)
return E_INVALIDARG;
}
bytesperrow = ((bpp * rc->Width)+7)/8;

View File

@ -799,12 +799,24 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
HRESULT hr=S_OK;
BYTE *dst_tilepos;
UINT bytesperrow;
WICRect rect;
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->decode_info.width ||
prc->Y+prc->Height > This->decode_info.height)
return E_INVALIDARG;
if (!prc)
{
rect.X = 0;
rect.Y = 0;
rect.Width = This->decode_info.width;
rect.Height = This->decode_info.height;
prc = &rect;
}
else
{
if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->decode_info.width ||
prc->Y+prc->Height > This->decode_info.height)
return E_INVALIDARG;
}
bytesperrow = ((This->decode_info.bpp * prc->Width)+7)/8;