diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 5c47126068..a2790a3366 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -81,7 +81,7 @@ @ stdcall GdipCreateBitmapFromScan0(long long long long ptr ptr) @ stdcall GdipCreateBitmapFromStream(ptr ptr) @ stdcall GdipCreateBitmapFromStreamICM(ptr ptr) -@ stub GdipCreateCachedBitmap +@ stdcall GdipCreateCachedBitmap(ptr ptr ptr) @ stdcall GdipCreateCustomLineCap(ptr ptr long long ptr) @ stub GdipCreateEffect @ stdcall GdipCreateFont(ptr long long long ptr) @@ -137,7 +137,7 @@ @ stdcall GdipCreateTextureIA(ptr ptr long long long long ptr) @ stdcall GdipCreateTextureIAI(ptr ptr long long long long ptr) @ stdcall GdipDeleteBrush(ptr) -@ stub GdipDeleteCachedBitmap +@ stdcall GdipDeleteCachedBitmap(ptr) @ stdcall GdipDeleteCustomLineCap(ptr) @ stub GdipDeleteEffect @ stdcall GdipDeleteFont(ptr) @@ -158,7 +158,7 @@ @ stdcall GdipDrawBezierI(ptr ptr long long long long long long long long) @ stdcall GdipDrawBeziers(ptr ptr ptr long) @ stdcall GdipDrawBeziersI(ptr ptr ptr long) -@ stub GdipDrawCachedBitmap +@ stdcall GdipDrawCachedBitmap(ptr ptr long long) @ stdcall GdipDrawClosedCurve2(ptr ptr ptr long long) @ stdcall GdipDrawClosedCurve2I(ptr ptr ptr long long) @ stdcall GdipDrawClosedCurve(ptr ptr ptr long) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 05549b4b18..d3dce6af94 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -195,6 +195,10 @@ struct GpBitmap{ BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */ }; +struct GpCachedBitmap{ + GpBitmap *bmp; +}; + struct GpImageAttributes{ WrapMode wrap; }; diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 9dbefc026c..16279951a2 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -547,6 +547,67 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream, return GdipCreateBitmapFromStream(stream, bitmap); } +GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphics, + GpCachedBitmap **cachedbmp) +{ + GpStatus stat; + GpImage *copy; + + TRACE("%p %p %p\n", bitmap, graphics, cachedbmp); + + if(!bitmap || !graphics || !cachedbmp) + return InvalidParameter; + + *cachedbmp = GdipAlloc(sizeof(GpCachedBitmap)); + if(!*cachedbmp) + return OutOfMemory; + (*cachedbmp)->bmp = GdipAlloc(sizeof(GpBitmap)); + if(!(*cachedbmp)->bmp){ + GdipFree(*cachedbmp); + return OutOfMemory; + } + + copy = &(*cachedbmp)->bmp->image; + stat = GdipCloneImage(&(bitmap->image), ©); + if(stat != Ok){ + GdipFree(*cachedbmp); + return stat; + } + + (*cachedbmp)->bmp->width = bitmap->width; + (*cachedbmp)->bmp->height = bitmap->height; + (*cachedbmp)->bmp->format = bitmap->format; + (*cachedbmp)->bmp->lockmode = 0; + (*cachedbmp)->bmp->numlocks = 0; + (*cachedbmp)->bmp->bitmapbits = NULL; + + return Ok; +} + +GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp) +{ + TRACE("%p\n", cachedbmp); + + if(!cachedbmp) + return InvalidParameter; + + GdipDisposeImage(&cachedbmp->bmp->image); + GdipFree(cachedbmp->bmp); + + return Ok; +} + +GpStatus WINGDIPAPI GdipDrawCachedBitmap(GpGraphics *graphics, + GpCachedBitmap *cachedbmp, INT x, INT y) +{ + TRACE("%p %p %d %d\n", graphics, cachedbmp, x, y); + + if(!graphics || !cachedbmp) + return InvalidParameter; + + return GdipDrawImage(graphics, &cachedbmp->bmp->image, (REAL)x, (REAL)y); +} + GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) { HDC hdc; diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index 917097ef8d..e1d1706edb 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -32,6 +32,7 @@ class GpAdjustableArrowCap : public GpCustomLineCap {}; class GpImage {}; class GpMetafile : public GpImage {}; class GpImageAttributes {}; +class GpCachedBitmap {}; class GpBitmap : public GpImage {}; class GpPathGradient : public GpBrush {}; class GpLineGradient : public GpBrush {}; @@ -57,6 +58,7 @@ typedef struct GpAdjustableArrowCap GpAdjustableArrowCap; typedef struct GpImage GpImage; typedef struct GpMetafile GpMetafile; typedef struct GpImageAttributes GpImageAttributes; +typedef struct GpCachedBitmap GpCachedBitmap; typedef struct GpBitmap GpBitmap; typedef struct GpPathGradient GpPathGradient; typedef struct GpLineGradient GpLineGradient;