gdiplus: Implemented and tested GdipGetImageDimension().
This commit is contained in:
parent
81dadcb1a1
commit
84d260ec60
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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*);
|
||||
|
|
Loading…
Reference in New Issue