Evan Stade : gdiplus: Track width and height of GpBitmaps.
Module: wine Branch: master Commit: 5cde960713de02e2864cadc7cadca2e95d37d84a URL: http://source.winehq.org/git/wine.git/?a=commit;h=5cde960713de02e2864cadc7ca... Author: Evan Stade <estade(a)gmail.com> Date: Tue Jul 31 19:16:20 2007 -0700 gdiplus: Track width and height of GpBitmaps. --- dlls/gdiplus/gdiplus_private.h | 2 + dlls/gdiplus/image.c | 92 +++++++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 602ca2c..168f6ff 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -130,6 +130,8 @@ struct GpMetafile{ struct GpBitmap{ GpImage image; + INT width; + INT height; }; struct GpImageAttributes{ diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index d23d9bb..d649e03 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -36,6 +36,39 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); typedef void ImageItemData; +static INT ipicture_pixel_height(IPicture *pic) +{ + HDC hdcref; + OLE_YSIZE_HIMETRIC y; + + IPicture_get_Height(pic, &y); + + hdcref = GetDC(0); + + y = (UINT)(((REAL)y) * ((REAL)GetDeviceCaps(hdcref, LOGPIXELSY)) / + ((REAL)INCH_HIMETRIC)); + ReleaseDC(0, hdcref); + + return y; +} + +static INT ipicture_pixel_width(IPicture *pic) +{ + HDC hdcref; + OLE_XSIZE_HIMETRIC x; + + IPicture_get_Width(pic, &x); + + hdcref = GetDC(0); + + x = (UINT)(((REAL)x) * ((REAL)GetDeviceCaps(hdcref, LOGPIXELSX)) / + ((REAL)INCH_HIMETRIC)); + + ReleaseDC(0, hdcref); + + return x; +} + GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) { @@ -110,6 +143,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, } (*bitmap)->image.type = ImageTypeBitmap; + (*bitmap)->width = width; + (*bitmap)->height = height; return Ok; } @@ -121,10 +156,14 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream, stat = GdipLoadImageFromStreamICM(stream, (GpImage**) bitmap); - if(stat == Ok) - (*bitmap)->image.type = ImageTypeBitmap; + if(stat != Ok) + return stat; + + (*bitmap)->image.type = ImageTypeBitmap; + (*bitmap)->width = ipicture_pixel_width((*bitmap)->image.picture); + (*bitmap)->height = ipicture_pixel_height((*bitmap)->image.picture); - return stat; + return Ok; } GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) @@ -155,25 +194,42 @@ GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, memcpy(srcRect, &((GpMetafile*)image)->bounds, sizeof(GpRectF)); *srcUnit = ((GpMetafile*)image)->unit; } + else if(image->type == ImageTypeBitmap){ + srcRect->X = srcRect->Y = 0.0; + srcRect->Width = (REAL) ((GpBitmap*)image)->width; + srcRect->Height = (REAL) ((GpBitmap*)image)->height; + *srcUnit = UnitPixel; + } else{ - FIXME("not implemented for bitmaps\n"); - return NotImplemented; + srcRect->X = srcRect->Y = 0.0; + srcRect->Width = ipicture_pixel_width(image->picture); + srcRect->Height = ipicture_pixel_height(image->picture); + *srcUnit = UnitPixel; } + TRACE("returning (%f, %f) (%f, %f) unit type %d\n", srcRect->X, srcRect->Y, + srcRect->Width, srcRect->Height, *srcUnit); + return Ok; } GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height) { - static int calls; - if(!image || !height) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + if(image->type == ImageTypeMetafile){ + FIXME("not implemented for metafiles\n"); + return NotImplemented; + } + else if(image->type == ImageTypeBitmap) + *height = ((GpBitmap*)image)->height; + else + *height = ipicture_pixel_height(image->picture); - return NotImplemented; + TRACE("returning %d\n", *height); + + return Ok; } GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res) @@ -227,15 +283,21 @@ GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res) GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width) { - static int calls; - if(!image || !width) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + if(image->type == ImageTypeMetafile){ + FIXME("not implemented for metafiles\n"); + return NotImplemented; + } + else if(image->type == ImageTypeBitmap) + *width = ((GpBitmap*)image)->width; + else + *width = ipicture_pixel_width(image->picture); - return NotImplemented; + TRACE("returning %d\n", *width); + + return Ok; } GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile * metafile,
participants (1)
-
Alexandre Julliard