gdiplus: Implement GdipRecordMetafileStream.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vincent Povirk 2016-04-06 14:36:58 -05:00 committed by Alexandre Julliard
parent 4ed1b4f5e8
commit a9e4e3b403
4 changed files with 57 additions and 7 deletions

View File

@ -343,6 +343,7 @@ struct GpMetafile{
BYTE *comment_data;
DWORD comment_data_size;
DWORD comment_data_length;
IStream *record_stream;
/* playback */
GpGraphics *playback_graphics;

View File

@ -6436,13 +6436,6 @@ GpStatus WINGDIPAPI GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16
brush, positions, flags, matrix);
}
GpStatus WINGDIPAPI GdipRecordMetafileStream(IStream *stream, HDC hdc, EmfType type, GDIPCONST GpRect *frameRect,
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
{
FIXME("(%p %p %d %p %d %p %p): stub\n", stream, hdc, type, frameRect, frameUnit, desc, metafile);
return NotImplemented;
}
/*****************************************************************************
* GdipIsVisibleClipEmpty [GDIPLUS.@]
*/

View File

@ -2142,6 +2142,10 @@ static GpStatus free_image_data(GpImage *image)
metafile->record_graphics->image = NULL;
metafile->record_graphics->busy = TRUE;
}
if (metafile->record_stream)
{
IStream_Release(metafile->record_stream);
}
}
else
{

View File

@ -308,6 +308,27 @@ GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect
return GdipRecordMetafile(hdc, type, pFrameRectF, frameUnit, desc, metafile);
}
GpStatus WINGDIPAPI GdipRecordMetafileStream(IStream *stream, HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect,
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
{
GpStatus stat;
TRACE("(%p %p %d %p %d %p %p)\n", stream, hdc, type, frameRect, frameUnit, desc, metafile);
if (!stream)
return InvalidParameter;
stat = GdipRecordMetafile(hdc, type, frameRect, frameUnit, desc, metafile);
if (stat == Ok)
{
(*metafile)->record_stream = stream;
IStream_AddRef(stream);
}
return stat;
}
GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result)
{
GpStatus stat;
@ -487,6 +508,37 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
}
}
if (stat == Ok && metafile->record_stream)
{
BYTE *buffer;
UINT buffer_size;
buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL);
buffer = heap_alloc(buffer_size);
if (buffer)
{
HRESULT hr;
GetEnhMetaFileBits(metafile->hemf, buffer_size, buffer);
hr = IStream_Write(metafile->record_stream, buffer, buffer_size, NULL);
if (FAILED(hr))
stat = hresult_to_status(hr);
heap_free(buffer);
}
else
stat = OutOfMemory;
}
if (metafile->record_stream)
{
IStream_Release(metafile->record_stream);
metafile->record_stream = NULL;
}
return stat;
}