gdi32: Calculate effective number of scan lines and truncate bitmap bits for EMR_SETDIBITSTODEVICE.
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
da126e19e3
commit
9301a9e1f8
|
@ -1815,6 +1815,7 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt
|
|||
EMRSETDIBITSTODEVICE *emr;
|
||||
BOOL ret;
|
||||
UINT bmi_size, img_size, payload_size, emr_size;
|
||||
UINT src_height, stride;
|
||||
BITMAPINFOHEADER bih;
|
||||
BITMAPINFO *bi;
|
||||
|
||||
|
@ -1822,6 +1823,25 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt
|
|||
if (!emf_parse_user_bitmapinfo( &bih, &info->bmiHeader, usage, TRUE,
|
||||
&bmi_size, &img_size )) return 0;
|
||||
|
||||
if (bih.biHeight >= 0)
|
||||
{
|
||||
src_height = (UINT)bih.biHeight;
|
||||
if (src_height > y_src + height) src_height = y_src + height;
|
||||
|
||||
if (src_height < startscan) lines = 0;
|
||||
else if (lines > src_height - startscan) lines = src_height - startscan;
|
||||
|
||||
if (!lines) return 0;
|
||||
|
||||
if (bih.biCompression == BI_RGB || bih.biCompression == BI_BITFIELDS)
|
||||
{
|
||||
/* truncate image and check for overflows */
|
||||
stride = get_dib_stride( bih.biWidth, bih.biBitCount );
|
||||
img_size = lines * stride;
|
||||
if (img_size / stride != lines) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for overflows */
|
||||
payload_size = bmi_size + img_size;
|
||||
if (payload_size < bmi_size) return 0;
|
||||
|
|
|
@ -7764,13 +7764,6 @@ static void test_emf_SetDIBitsToDevice(void)
|
|||
{
|
||||
winetest_push_context("Test %d", test_idx);
|
||||
|
||||
if (tests[test_idx].height != bitmap_height && !strcmp(winetest_platform, "wine"))
|
||||
{
|
||||
skip("Wine does not adjust cLines appropriately\n");
|
||||
winetest_pop_context();
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
if (tests[test_idx].infomode < 2)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue