Commit b6c52ce9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Implemented GdipCloneImage.

parent bff1678f
...@@ -242,11 +242,50 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, ...@@ -242,11 +242,50 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage) GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
{ {
if (!(image && cloneImage)) return InvalidParameter; IStream* stream;
HRESULT hr;
INT size;
FIXME("stub: %p, %p\n", image, cloneImage); TRACE("%p, %p\n", image, cloneImage);
return NotImplemented; if (!image || !cloneImage)
return InvalidParameter;
hr = CreateStreamOnHGlobal(0, TRUE, &stream);
if (FAILED(hr))
return GenericError;
*cloneImage = GdipAlloc(sizeof(GpImage));
if (!*cloneImage)
{
IStream_Release(stream);
return OutOfMemory;
}
(*cloneImage)->type = image->type;
(*cloneImage)->flags = image->flags;
hr = IPicture_SaveAsFile(image->picture, stream, FALSE, &size);
if(FAILED(hr))
{
WARN("Failed to save image on stream\n");
goto out;
}
hr = OleLoadPicture(stream, size, FALSE, &IID_IPicture,
(LPVOID*) &(*cloneImage)->picture);
if (FAILED(hr))
{
WARN("Failed to load image from stream\n");
goto out;
}
IStream_Release(stream);
return Ok;
out:
IStream_Release(stream);
GdipFree(*cloneImage);
*cloneImage = NULL;
return GenericError;
} }
GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename, GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
......
...@@ -504,22 +504,19 @@ static void test_GdipCloneImage(void) ...@@ -504,22 +504,19 @@ static void test_GdipCloneImage(void)
/* Create an image, clone it, delete the original, make sure the copy works */ /* Create an image, clone it, delete the original, make sure the copy works */
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm); stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat); expect(Ok, stat);
todo_wine
{
image_src = ((GpImage*)bm); image_src = ((GpImage*)bm);
stat = GdipCloneImage(image_src, &image_dest); stat = GdipCloneImage(image_src, &image_dest);
expect(Ok, stat); expect(Ok, stat);
}
stat = GdipDisposeImage((GpImage*)bm); stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat); expect(Ok, stat);
todo_wine
{
stat = GdipGetImageBounds(image_dest, &rectF, &unit); stat = GdipGetImageBounds(image_dest, &rectF, &unit);
expect(Ok, stat); expect(Ok, stat);
stat = GdipDisposeImage(image_dest); stat = GdipDisposeImage(image_dest);
expect(Ok, stat); expect(Ok, stat);
} }
}
START_TEST(image) START_TEST(image)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment