diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 0b570271614..2660c71919a 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -78,7 +78,7 @@ @ stub GdipCreateBitmapFromHBITMAP @ stub GdipCreateBitmapFromHICON @ stub GdipCreateBitmapFromResource -@ stub GdipCreateBitmapFromScan0 +@ stdcall GdipCreateBitmapFromScan0(long long long long ptr ptr) @ stub GdipCreateBitmapFromStream @ stub GdipCreateBitmapFromStreamICM @ stub GdipCreateCachedBitmap diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index c31de0ec113..602ca2ca1a4 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -128,6 +128,10 @@ struct GpMetafile{ GpUnit unit; }; +struct GpBitmap{ + GpImage image; +}; + struct GpImageAttributes{ WrapMode wrap; }; diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 00d0a581a17..6e78308057e 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -26,6 +26,7 @@ #define COBJMACROS #include "objbase.h" #include "olectl.h" +#include "ole2.h" #include "gdiplus.h" #include "gdiplus_private.h" @@ -35,6 +36,67 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); typedef void ImageItemData; +GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, + PixelFormat format, BYTE* scan0, GpBitmap** bitmap) +{ + BITMAPFILEHEADER *bmfh; + BITMAPINFOHEADER *bmih; + BYTE *buff; + INT datalen = stride * height, size; + IStream *stream; + + TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap); + + if(!scan0 || !bitmap) + return InvalidParameter; + + *bitmap = GdipAlloc(sizeof(GpBitmap)); + if(!*bitmap) return OutOfMemory; + + size = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + datalen; + buff = GdipAlloc(size); + if(!buff){ + GdipFree(*bitmap); + return OutOfMemory; + } + + bmfh = (BITMAPFILEHEADER*) buff; + bmih = (BITMAPINFOHEADER*) (bmfh + 1); + + bmfh->bfType = (((WORD)'M') << 8) + (WORD)'B'; + bmfh->bfSize = size; + bmfh->bfOffBits = size - datalen; + + bmih->biSize = sizeof(BITMAPINFOHEADER); + bmih->biWidth = width; + bmih->biHeight = height; + /* FIXME: use the rest of the data from format */ + bmih->biBitCount = format >> 8; + bmih->biCompression = BI_RGB; + + memcpy(bmih + 1, scan0, datalen); + + if(CreateStreamOnHGlobal(buff, TRUE, &stream) != S_OK){ + ERR("could not make stream\n"); + GdipFree(*bitmap); + GdipFree(buff); + return GenericError; + } + + if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture, + (LPVOID*) &((*bitmap)->image.picture)) != S_OK){ + TRACE("Could not load picture\n"); + IStream_Release(stream); + GdipFree(*bitmap); + GdipFree(buff); + return GenericError; + } + + (*bitmap)->image.type = ImageTypeBitmap; + + return Ok; +} + GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) { if(!image) diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 348d7c033c6..4ed101118db 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -138,6 +138,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath*,GpPath*,GpLineCap,REAL, GpCustomLineCap**); GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap*); +GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT,INT,INT,PixelFormat,BYTE*, + GpBitmap**); GpStatus WINGDIPAPI GdipDisposeImage(GpImage*); GpStatus WINGDIPAPI GdipGetImageBounds(GpImage*,GpRectF*,GpUnit*); GpStatus WINGDIPAPI GdipGetImageHeight(GpImage*,UINT*); diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index 30a04d222c3..fec691affd0 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -32,6 +32,7 @@ class GpCustomLineCap {}; class GpImage {}; class GpMetafile : public GpImage {}; class GpImageAttributes {}; +class GpBitmap : public GpImage {}; #else /* end of c++ declarations */ @@ -46,6 +47,7 @@ typedef struct GpCustomLineCap GpCustomLineCap; typedef struct GpImage GpImage; typedef struct GpMetafile GpMetafile; typedef struct GpImageAttributes GpImageAttributes; +typedef struct GpBitmap GpBitmap; #endif /* end of c declarations */ diff --git a/include/gdipluspixelformats.h b/include/gdipluspixelformats.h index b2110c1f49a..6f50492e775 100644 --- a/include/gdipluspixelformats.h +++ b/include/gdipluspixelformats.h @@ -20,5 +20,6 @@ #define _GDIPLUSPIXELFORMATS_H typedef DWORD ARGB; +typedef INT PixelFormat; #endif