From: Tobiasz Laskowski <tlaskowski@codeweavers.com> As stated in the documentation, the attribute id is optional: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-emfplus/778... --- dlls/gdiplus/metafile.c | 14 ++++++++++---- dlls/gdiplus/tests/metafile.c | 4 ---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 83484b9a00e..b9323559582 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -3218,6 +3218,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, { EmfPlusDrawImage *draw = (EmfPlusDrawImage *)header; BYTE image = flags & 0xff; + GpImageAttributes *attributes; GpPointF points[3]; if (image >= EmfPlusObjectTableSize || real_metafile->objtable[image].type != ObjectTypeImage) @@ -3229,7 +3230,9 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, if (draw->ImageAttributesID >= EmfPlusObjectTableSize || real_metafile->objtable[draw->ImageAttributesID].type != ObjectTypeImageAttributes) - return InvalidParameter; + attributes = NULL; + else + attributes = real_metafile->objtable[draw->ImageAttributesID].u.image_attributes; if (flags & 0x4000) /* C */ { @@ -3252,7 +3255,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, return GdipDrawImagePointsRect(real_metafile->playback_graphics, real_metafile->objtable[image].u.image, points, 3, draw->SrcRect.X, draw->SrcRect.Y, draw->SrcRect.Width, draw->SrcRect.Height, draw->SrcUnit, - real_metafile->objtable[draw->ImageAttributesID].u.image_attributes, NULL, NULL); + attributes, NULL, NULL); } case EmfPlusRecordTypeDrawImagePoints: { @@ -3260,6 +3263,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, static const UINT fixed_part_size = FIELD_OFFSET(EmfPlusDrawImagePoints, PointData) - FIELD_OFFSET(EmfPlusDrawImagePoints, ImageAttributesID); BYTE image = flags & 0xff; + GpImageAttributes* attributes; GpPointF points[3]; unsigned int i; UINT size; @@ -3273,7 +3277,9 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, if (draw->ImageAttributesID >= EmfPlusObjectTableSize || real_metafile->objtable[draw->ImageAttributesID].type != ObjectTypeImageAttributes) - return InvalidParameter; + attributes = NULL; + else + attributes = real_metafile->objtable[draw->ImageAttributesID].u.image_attributes; if (draw->count != 3) return InvalidParameter; @@ -3314,7 +3320,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, return GdipDrawImagePointsRect(real_metafile->playback_graphics, real_metafile->objtable[image].u.image, points, 3, draw->SrcRect.X, draw->SrcRect.Y, draw->SrcRect.Width, draw->SrcRect.Height, draw->SrcUnit, - real_metafile->objtable[draw->ImageAttributesID].u.image_attributes, NULL, NULL); + attributes, NULL, NULL); } case EmfPlusRecordTypeFillPath: { diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 3cee0695667..b0315acbf98 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -2700,21 +2700,18 @@ static BOOL CALLBACK play_drawimage_proc(EmfPlusRecordType recordType, UINT flag stat = GdipPlayMetafileRecord(ctx->metafile, ctx->record->Header.Type, ctx->record->Header.Flags, ctx->record->Header.DataSize, (const BYTE*)&ctx->record->ImageAttributesID); - todo_wine expect(Ok, stat); ctx->record->ImageAttributesID = (DWORD)-2; stat = GdipPlayMetafileRecord(ctx->metafile, ctx->record->Header.Type, ctx->record->Header.Flags, ctx->record->Header.DataSize, (const BYTE*)&ctx->record->ImageAttributesID); - todo_wine expect(Ok, stat); ctx->record->ImageAttributesID = (DWORD)64; stat = GdipPlayMetafileRecord(ctx->metafile, ctx->record->Header.Type, ctx->record->Header.Flags, ctx->record->Header.DataSize, (const BYTE*)&ctx->record->ImageAttributesID); - todo_wine expect(Ok, stat); /* Within bounds, but missing */ @@ -2722,7 +2719,6 @@ static BOOL CALLBACK play_drawimage_proc(EmfPlusRecordType recordType, UINT flag stat = GdipPlayMetafileRecord(ctx->metafile, ctx->record->Header.Type, ctx->record->Header.Flags, ctx->record->Header.DataSize, (const BYTE*)&ctx->record->ImageAttributesID); - todo_wine expect(Ok, stat); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11714