gdiplus: Implement GdipGetImage*Resolution.
This commit is contained in:
parent
f71cb580a4
commit
1aea88cac1
|
@ -219,6 +219,7 @@ struct GpImage{
|
||||||
UINT palette_count;
|
UINT palette_count;
|
||||||
UINT palette_size;
|
UINT palette_size;
|
||||||
ARGB *palette_entries;
|
ARGB *palette_entries;
|
||||||
|
REAL xres, yres;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpMetafile{
|
struct GpMetafile{
|
||||||
|
|
|
@ -1262,6 +1262,8 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
|
||||||
(*metafile)->image.palette_count = 0;
|
(*metafile)->image.palette_count = 0;
|
||||||
(*metafile)->image.palette_size = 0;
|
(*metafile)->image.palette_size = 0;
|
||||||
(*metafile)->image.palette_entries = NULL;
|
(*metafile)->image.palette_entries = NULL;
|
||||||
|
(*metafile)->image.xres = (REAL)placeable->Inch;
|
||||||
|
(*metafile)->image.yres = (REAL)placeable->Inch;
|
||||||
(*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
|
(*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
|
||||||
(*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch);
|
(*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch);
|
||||||
(*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
|
(*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
|
||||||
|
|
|
@ -1172,6 +1172,20 @@ static void generate_halftone_palette(ARGB *entries, UINT count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GpStatus get_screen_resolution(REAL *xres, REAL *yres)
|
||||||
|
{
|
||||||
|
HDC screendc = GetDC(0);
|
||||||
|
|
||||||
|
if (!screendc) return GenericError;
|
||||||
|
|
||||||
|
*xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX);
|
||||||
|
*yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY);
|
||||||
|
|
||||||
|
ReleaseDC(0, screendc);
|
||||||
|
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
||||||
PixelFormat format, BYTE* scan0, GpBitmap** bitmap)
|
PixelFormat format, BYTE* scan0, GpBitmap** bitmap)
|
||||||
{
|
{
|
||||||
|
@ -1181,6 +1195,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
BYTE *bits;
|
BYTE *bits;
|
||||||
int i;
|
int i;
|
||||||
|
REAL xres, yres;
|
||||||
|
GpStatus stat;
|
||||||
|
|
||||||
TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap);
|
TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap);
|
||||||
|
|
||||||
|
@ -1194,6 +1210,9 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
||||||
if(scan0 && !stride)
|
if(scan0 && !stride)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
stat = get_screen_resolution(&xres, &yres);
|
||||||
|
if (stat != Ok) return stat;
|
||||||
|
|
||||||
row_size = (width * PIXELFORMATBPP(format)+7) / 8;
|
row_size = (width * PIXELFORMATBPP(format)+7) / 8;
|
||||||
dib_stride = (row_size + 3) & ~3;
|
dib_stride = (row_size + 3) & ~3;
|
||||||
|
|
||||||
|
@ -1243,6 +1262,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
||||||
(*bitmap)->image.palette_count = 0;
|
(*bitmap)->image.palette_count = 0;
|
||||||
(*bitmap)->image.palette_size = 0;
|
(*bitmap)->image.palette_size = 0;
|
||||||
(*bitmap)->image.palette_entries = NULL;
|
(*bitmap)->image.palette_entries = NULL;
|
||||||
|
(*bitmap)->image.xres = xres;
|
||||||
|
(*bitmap)->image.yres = yres;
|
||||||
(*bitmap)->width = width;
|
(*bitmap)->width = width;
|
||||||
(*bitmap)->height = height;
|
(*bitmap)->height = height;
|
||||||
(*bitmap)->format = format;
|
(*bitmap)->format = format;
|
||||||
|
@ -1522,15 +1543,14 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
|
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
|
|
||||||
if(!image || !res)
|
if(!image || !res)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
*res = image->xres;
|
||||||
FIXME("not implemented\n");
|
|
||||||
|
|
||||||
return NotImplemented;
|
TRACE("(%p) <-- %0.2f\n", image, *res);
|
||||||
|
|
||||||
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size)
|
GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size)
|
||||||
|
@ -1590,15 +1610,14 @@ GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type)
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
|
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
|
|
||||||
if(!image || !res)
|
if(!image || !res)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
*res = image->yres;
|
||||||
FIXME("not implemented\n");
|
|
||||||
|
|
||||||
return NotImplemented;
|
TRACE("(%p) <-- %0.2f\n", image, *res);
|
||||||
|
|
||||||
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
|
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
|
||||||
|
|
|
@ -843,11 +843,11 @@ static void test_loadwmf(void)
|
||||||
todo_wine expectf(320.0, bounds.Height);
|
todo_wine expectf(320.0, bounds.Height);
|
||||||
|
|
||||||
stat = GdipGetImageHorizontalResolution(img, &res);
|
stat = GdipGetImageHorizontalResolution(img, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(1440.0, res);
|
todo_wine expectf(1440.0, res);
|
||||||
|
|
||||||
stat = GdipGetImageVerticalResolution(img, &res);
|
stat = GdipGetImageVerticalResolution(img, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(1440.0, res);
|
todo_wine expectf(1440.0, res);
|
||||||
|
|
||||||
GdipDisposeImage(img);
|
GdipDisposeImage(img);
|
||||||
|
@ -879,12 +879,12 @@ static void test_createfromwmf(void)
|
||||||
todo_wine expectf(320.0, bounds.Height);
|
todo_wine expectf(320.0, bounds.Height);
|
||||||
|
|
||||||
stat = GdipGetImageHorizontalResolution(img, &res);
|
stat = GdipGetImageHorizontalResolution(img, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(1440.0, res);
|
expectf(1440.0, res);
|
||||||
|
|
||||||
stat = GdipGetImageVerticalResolution(img, &res);
|
stat = GdipGetImageVerticalResolution(img, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(1440.0, res);
|
expectf(1440.0, res);
|
||||||
|
|
||||||
GdipDisposeImage(img);
|
GdipDisposeImage(img);
|
||||||
}
|
}
|
||||||
|
@ -929,23 +929,23 @@ static void test_resolution(void)
|
||||||
ReleaseDC(0, screendc);
|
ReleaseDC(0, screendc);
|
||||||
|
|
||||||
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf((REAL)screenxres, res);
|
expectf((REAL)screenxres, res);
|
||||||
|
|
||||||
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf((REAL)screenyres, res);
|
expectf((REAL)screenyres, res);
|
||||||
|
|
||||||
/* test changing the resolution */
|
/* test changing the resolution */
|
||||||
stat = GdipBitmapSetResolution(bitmap, screenxres*2.0, screenyres*3.0);
|
stat = GdipBitmapSetResolution(bitmap, screenxres*2.0, screenyres*3.0);
|
||||||
todo_wine expect(Ok, stat);
|
todo_wine expect(Ok, stat);
|
||||||
|
|
||||||
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(screenxres*2.0, res);
|
todo_wine expectf(screenxres*2.0, res);
|
||||||
|
|
||||||
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
||||||
todo_wine expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
todo_wine expectf(screenyres*3.0, res);
|
todo_wine expectf(screenyres*3.0, res);
|
||||||
|
|
||||||
stat = GdipDisposeImage((GpImage*)bitmap);
|
stat = GdipDisposeImage((GpImage*)bitmap);
|
||||||
|
|
Loading…
Reference in New Issue