gdiplus: Implemented GdipCloneImage.

This commit is contained in:
Nikolay Sivov 2008-09-05 14:41:49 +04:00 committed by Alexandre Julliard
parent bff1678f54
commit b6c52ce996
2 changed files with 45 additions and 9 deletions

View File

@ -242,11 +242,50 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
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,

View File

@ -504,22 +504,19 @@ static void test_GdipCloneImage(void)
/* Create an image, clone it, delete the original, make sure the copy works */
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat);
todo_wine
{
image_src = ((GpImage*)bm);
stat = GdipCloneImage(image_src, &image_dest);
expect(Ok, stat);
}
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
todo_wine
{
stat = GdipGetImageBounds(image_dest, &rectF, &unit);
expect(Ok, stat);
stat = GdipDisposeImage(image_dest);
expect(Ok, stat);
}
}
START_TEST(image)
{