From bf04d3fa6915145b5c797e75b41002da2d40cc5c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sun, 6 Dec 2009 20:02:35 -0600 Subject: [PATCH] gdiplus: Implement GdipCloneBitmapArea. --- dlls/gdiplus/image.c | 64 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 5b70918aa07..22895c7d0cb 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -607,17 +607,73 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, PixelFormat format, GpBitmap* srcBitmap, GpBitmap** dstBitmap) { - FIXME("(%f,%f,%f,%f,%i,%p,%p): stub\n", x, y, width, height, format, srcBitmap, dstBitmap); + BitmapData lockeddata_src, lockeddata_dst; + int i; + UINT row_size; + Rect area; + GpStatus stat; - return NotImplemented; + TRACE("(%f,%f,%f,%f,%i,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); + + if (!srcBitmap || !dstBitmap || srcBitmap->image.type != ImageTypeBitmap || + x < 0 || y < 0 || + x + width > srcBitmap->width || y + height > srcBitmap->height) + { + TRACE("<-- InvalidParameter\n"); + return InvalidParameter; + } + + if (format == PixelFormatDontCare) + format = srcBitmap->format; + + area.X = roundr(x); + area.Y = roundr(y); + area.Width = roundr(width); + area.Height = roundr(height); + + stat = GdipBitmapLockBits(srcBitmap, &area, ImageLockModeRead, format, + &lockeddata_src); + if (stat != Ok) return stat; + + stat = GdipCreateBitmapFromScan0(lockeddata_src.Width, lockeddata_src.Height, + 0, lockeddata_src.PixelFormat, NULL, dstBitmap); + if (stat == Ok) + { + stat = GdipBitmapLockBits(*dstBitmap, NULL, ImageLockModeWrite, + lockeddata_src.PixelFormat, &lockeddata_dst); + + if (stat == Ok) + { + /* copy the image data */ + row_size = (lockeddata_src.Width * PIXELFORMATBPP(lockeddata_src.PixelFormat) +7)/8; + for (i=0; i