Commit 84d260ec authored by Jon Yang's avatar Jon Yang Committed by Alexandre Julliard

gdiplus: Implemented and tested GdipGetImageDimension().

parent 81dadcb1
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
@ stdcall GdipGetImageBounds(ptr ptr ptr) @ stdcall GdipGetImageBounds(ptr ptr ptr)
@ stub GdipGetImageDecoders @ stub GdipGetImageDecoders
@ stub GdipGetImageDecodersSize @ stub GdipGetImageDecodersSize
@ stub GdipGetImageDimension @ stdcall GdipGetImageDimension(ptr ptr ptr)
@ stub GdipGetImageEncoders @ stub GdipGetImageEncoders
@ stub GdipGetImageEncodersSize @ stub GdipGetImageEncodersSize
@ stub GdipGetImageFlags @ stub GdipGetImageFlags
......
...@@ -463,6 +463,37 @@ GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, ...@@ -463,6 +463,37 @@ GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect,
return Ok; 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, GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
GpGraphics **graphics) GpGraphics **graphics)
{ {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "windows.h" #include "windows.h"
#include "gdiplus.h" #include "gdiplus.h"
#include "wine/test.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) #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) ...@@ -73,6 +74,37 @@ static void test_Scan0(void)
expect(0xdeadbeef, bm); 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) START_TEST(image)
{ {
struct GdiplusStartupInput gdiplusStartupInput; struct GdiplusStartupInput gdiplusStartupInput;
...@@ -86,6 +118,7 @@ START_TEST(image) ...@@ -86,6 +118,7 @@ START_TEST(image)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_Scan0(); test_Scan0();
test_GetImageDimension();
GdiplusShutdown(gdiplusToken); GdiplusShutdown(gdiplusToken);
} }
...@@ -114,6 +114,7 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics*,GpBrush*,REAL,REAL,REAL,REAL); ...@@ -114,6 +114,7 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics*,GpBrush*,REAL,REAL,REAL,REAL);
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics*,GpBrush*,INT,INT,INT,INT); GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics*,GpBrush*,INT,INT,INT,INT);
GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics*,CompositingMode*); GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics*,CompositingMode*);
GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics*,CompositingQuality*); GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics*,CompositingQuality*);
GpStatus WINGDIPAPI GdipGetImageDimension(GpImage*,REAL*,REAL*);
GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics*,InterpolationMode*); GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics*,InterpolationMode*);
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics*,REAL*); GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics*,REAL*);
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics*,GpUnit*); GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics*,GpUnit*);
......
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