From 7dfc674437a113ea2f515dfbc03270c0be42e41b Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 8 May 2010 13:29:53 -0500 Subject: [PATCH] gdiplus: Implement GdipGetImageThumbnail. --- dlls/gdiplus/image.c | 41 +++++++++++++++++++++++++++++++++++++++-- dlls/gdiplus/tests/image.c | 10 +++++----- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 0eaaf2e20ab..8b551154e77 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -3515,9 +3515,46 @@ GpStatus WINGDIPAPI GdipGetImageThumbnail(GpImage *image, UINT width, UINT heigh GpImage **ret_image, GetThumbnailImageAbort cb, VOID * cb_data) { - FIXME("(%p %u %u %p %p %p) stub\n", + GpStatus stat; + GpGraphics *graphics; + UINT srcwidth, srcheight; + + TRACE("(%p %u %u %p %p %p)\n", image, width, height, ret_image, cb, cb_data); - return NotImplemented; + + if (!image || !ret_image) + return InvalidParameter; + + if (!width) width = 120; + if (!height) height = 120; + + GdipGetImageWidth(image, &srcwidth); + GdipGetImageHeight(image, &srcheight); + + stat = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppARGB, + NULL, (GpBitmap**)ret_image); + + if (stat == Ok) + { + stat = GdipGetImageGraphicsContext(*ret_image, &graphics); + + if (stat == Ok) + { + stat = GdipDrawImageRectRectI(graphics, image, + 0, 0, width, height, 0, 0, srcwidth, srcheight, UnitPixel, + NULL, NULL, NULL); + + GdipDeleteGraphics(graphics); + } + + if (stat != Ok) + { + GdipDisposeImage(*ret_image); + *ret_image = NULL; + } + } + + return stat; } /***************************************************************************** diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 8abb40c5be5..0e33049a5b7 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -1219,16 +1219,16 @@ static void test_getthumbnail(void) UINT width, height; stat = GdipGetImageThumbnail(NULL, 0, 0, &bitmap2, NULL, NULL); - todo_wine expect(InvalidParameter, stat); + expect(InvalidParameter, stat); stat = GdipCreateBitmapFromScan0(128, 128, 0, PixelFormat32bppRGB, NULL, (GpBitmap**)&bitmap1); expect(Ok, stat); stat = GdipGetImageThumbnail(bitmap1, 0, 0, NULL, NULL, NULL); - todo_wine expect(InvalidParameter, stat); + expect(InvalidParameter, stat); stat = GdipGetImageThumbnail(bitmap1, 0, 0, &bitmap2, NULL, NULL); - todo_wine expect(Ok, stat); + expect(Ok, stat); if (stat == Ok) { @@ -1250,7 +1250,7 @@ static void test_getthumbnail(void) expect(Ok, stat); stat = GdipGetImageThumbnail(bitmap1, 32, 32, &bitmap2, NULL, NULL); - todo_wine expect(Ok, stat); + expect(Ok, stat); if (stat == Ok) { @@ -1266,7 +1266,7 @@ static void test_getthumbnail(void) } stat = GdipGetImageThumbnail(bitmap1, 0, 0, &bitmap2, NULL, NULL); - todo_wine expect(Ok, stat); + expect(Ok, stat); if (stat == Ok) { -- 2.11.4.GIT