gdiplus: Added GdipCreateBitmapFromScan0.
This commit is contained in:
parent
4c5486fe92
commit
9fa4c12486
|
@ -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
|
||||
|
|
|
@ -128,6 +128,10 @@ struct GpMetafile{
|
|||
GpUnit unit;
|
||||
};
|
||||
|
||||
struct GpBitmap{
|
||||
GpImage image;
|
||||
};
|
||||
|
||||
struct GpImageAttributes{
|
||||
WrapMode wrap;
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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*);
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
#define _GDIPLUSPIXELFORMATS_H
|
||||
|
||||
typedef DWORD ARGB;
|
||||
typedef INT PixelFormat;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue