[13/21] gdiplus: added GdipCreateBitmapFromScan0
Evan Stade
estade at gmail.com
Tue Jul 31 21:15:52 CDT 2007
Hi,
changelog:
*added minimal GdipCreateBitmapFromScan0 implementation
*initial GpBitmap definition
dlls/gdiplus/gdiplus.spec | 2 +
dlls/gdiplus/gdiplus_private.h | 4 +++
dlls/gdiplus/image.c | 62 ++++++++++++++++++++++++++++++++++++++++
include/gdiplusflat.h | 2 +
include/gdiplusgpstubs.h | 2 +
include/gdipluspixelformats.h | 1 +
6 files changed, 72 insertions(+), 1 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 0b57027..2660c71 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 c31de0e..602ca2c 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 00d0a58..6e78308 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -26,6 +26,7 @@ #include "wingdi.h"
#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 348d7c0..4ed1011 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -138,6 +138,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLine
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 30a04d2..fec691a 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 GpCustomL
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 b2110c1..6f50492 100644
--- a/include/gdipluspixelformats.h
+++ b/include/gdipluspixelformats.h
@@ -20,5 +20,6 @@ #ifndef _GDIPLUSPIXELFORMATS_H
#define _GDIPLUSPIXELFORMATS_H
typedef DWORD ARGB;
+typedef INT PixelFormat;
#endif
--
1.4.1
More information about the wine-patches
mailing list