Jon Yang : gdiplus: Implemented and tested GdipGetImageDimension().
Alexandre Julliard
julliard at winehq.org
Fri Feb 29 06:17:12 CST 2008
Module: wine
Branch: master
Commit: 84d260ec60605c0eb1a938b33cc3e8c282740372
URL: http://source.winehq.org/git/wine.git/?a=commit;h=84d260ec60605c0eb1a938b33cc3e8c282740372
Author: Jon Yang <jyang08 at ucla.edu>
Date: Wed Feb 27 01:36:44 2008 -0800
gdiplus: Implemented and tested GdipGetImageDimension().
---
dlls/gdiplus/gdiplus.spec | 2 +-
dlls/gdiplus/image.c | 31 +++++++++++++++++++++++++++++++
dlls/gdiplus/tests/image.c | 33 +++++++++++++++++++++++++++++++++
include/gdiplusflat.h | 1 +
4 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 55fabe4..a2d3183 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -283,7 +283,7 @@
@ stdcall GdipGetImageBounds(ptr ptr ptr)
@ stub GdipGetImageDecoders
@ stub GdipGetImageDecodersSize
-@ stub GdipGetImageDimension
+@ stdcall GdipGetImageDimension(ptr ptr ptr)
@ stub GdipGetImageEncoders
@ stub GdipGetImageEncodersSize
@ stub GdipGetImageFlags
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index b08c5e5..0fe7dfe 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -463,6 +463,37 @@ GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect,
return Ok;
}
+GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width,
+ REAL *height)
+{
+ if(!image || !height || !width)
+ return InvalidParameter;
+
+ if(image->type == ImageTypeMetafile){
+ HDC hdc = GetDC(0);
+
+ *height = convert_unit(hdc, ((GpMetafile*)image)->unit) *
+ ((GpMetafile*)image)->bounds.Height;
+
+ *width = convert_unit(hdc, ((GpMetafile*)image)->unit) *
+ ((GpMetafile*)image)->bounds.Width;
+
+ ReleaseDC(0, hdc);
+ }
+
+ else if(image->type == ImageTypeBitmap){
+ *height = ((GpBitmap*)image)->height;
+ *width = ((GpBitmap*)image)->width;
+ }
+ else{
+ *height = ipicture_pixel_height(image->picture);
+ *width = ipicture_pixel_width(image->picture);
+ }
+
+ TRACE("returning (%f, %f)\n", *height, *width);
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
GpGraphics **graphics)
{
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 0364962..d0959e5 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -21,6 +21,7 @@
#include "windows.h"
#include "gdiplus.h"
#include "wine/test.h"
+#include <math.h>
#define expect(expected, got) ok(((UINT)got) == ((UINT)expected), "Expected %.8x, got %.8x\n", (UINT)expected, (UINT)got)
@@ -73,6 +74,37 @@ static void test_Scan0(void)
expect(0xdeadbeef, bm);
}
+static void test_GetImageDimension(void)
+{
+ GpBitmap *bm;
+ GpStatus stat;
+ const REAL WIDTH = 10.0, HEIGHT = 20.0;
+ REAL w,h;
+
+ bm = (GpBitmap*)0xdeadbeef;
+ stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB,NULL, &bm);
+ expect(Ok,stat);
+ ok((GpBitmap*)0xdeadbeef != bm, "Expected bitmap to not be 0xdeadbeef\n");
+ ok(NULL != bm, "Expected bitmap to not be NULL\n");
+
+ stat = GdipGetImageDimension(NULL,&w,&h);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageDimension((GpImage*)bm,NULL,&h);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageDimension((GpImage*)bm,&w,NULL);
+ expect(InvalidParameter, stat);
+
+ w = -1;
+ h = -1;
+ stat = GdipGetImageDimension((GpImage*)bm,&w,&h);
+ expect(Ok, stat);
+ ok(fabs(WIDTH - w) < 0.0001, "Width wrong");
+ ok(fabs(HEIGHT - h) < 0.0001, "Height wrong");
+ GdipDisposeImage((GpImage*)bm);
+}
+
START_TEST(image)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -86,6 +118,7 @@ START_TEST(image)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_Scan0();
+ test_GetImageDimension();
GdiplusShutdown(gdiplusToken);
}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index caf3532..1f635ba 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -114,6 +114,7 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics*,GpBrush*,REAL,REAL,REAL,REAL);
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics*,GpBrush*,INT,INT,INT,INT);
GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics*,CompositingMode*);
GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics*,CompositingQuality*);
+GpStatus WINGDIPAPI GdipGetImageDimension(GpImage*,REAL*,REAL*);
GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics*,InterpolationMode*);
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics*,REAL*);
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics*,GpUnit*);
More information about the wine-cvs
mailing list