Commit 4d25791b authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdiplus: Added GdipGetImagePixelFormat.

parent f3879cd9
......@@ -293,7 +293,7 @@
@ stub GdipGetImageItemData
@ stub GdipGetImagePalette
@ stub GdipGetImagePaletteSize
@ stub GdipGetImagePixelFormat
@ stdcall GdipGetImagePixelFormat(ptr ptr)
@ stdcall GdipGetImageRawFormat(ptr ptr)
@ stub GdipGetImageThumbnail
@ stdcall GdipGetImageType(ptr ptr)
......
......@@ -142,6 +142,7 @@ struct GpBitmap{
GpImage image;
INT width;
INT height;
PixelFormat format;
};
struct GpImageAttributes{
......
......@@ -36,6 +36,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
typedef void ImageItemData;
#define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24)
static INT ipicture_pixel_height(IPicture *pic)
{
HDC hdcref;
......@@ -121,7 +123,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
bmih->biWidth = width;
bmih->biHeight = height;
/* FIXME: use the rest of the data from format */
bmih->biBitCount = format >> 8;
bmih->biBitCount = PIXELFORMATBPP(format);
bmih->biCompression = BI_RGB;
memcpy(bmih + 1, scan0, datalen);
......@@ -145,6 +147,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
(*bitmap)->image.type = ImageTypeBitmap;
(*bitmap)->width = width;
(*bitmap)->height = height;
(*bitmap)->format = format;
return Ok;
}
......@@ -152,6 +155,10 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
GpBitmap **bitmap)
{
BITMAPINFO bmi;
BITMAPCOREHEADER* bmch;
OLE_HANDLE hbm;
HDC hdc;
GpStatus stat;
stat = GdipLoadImageFromStream(stream, (GpImage**) bitmap);
......@@ -164,24 +171,34 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
(*bitmap)->width = ipicture_pixel_width((*bitmap)->image.picture);
(*bitmap)->height = ipicture_pixel_height((*bitmap)->image.picture);
/* get the pixel format */
IPicture_get_Handle((*bitmap)->image.picture, &hbm);
IPicture_get_CurDC((*bitmap)->image.picture, &hdc);
bmch = (BITMAPCOREHEADER*) (&bmi.bmiHeader);
bmch->bcSize = sizeof(BITMAPCOREHEADER);
if(!hdc){
HBITMAP old;
hdc = GetDC(0);
old = SelectObject(hdc, (HBITMAP)hbm);
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
SelectObject(hdc, old);
ReleaseDC(0, hdc);
}
else
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
(*bitmap)->format = (bmch->bcBitCount << 8) | PixelFormatGDI;
return Ok;
}
/* FIXME: no icm */
GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream,
GpBitmap **bitmap)
{
GpStatus stat;
stat = GdipLoadImageFromStreamICM(stream, (GpImage**) bitmap);
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 Ok;
return GdipCreateBitmapFromStream(stream, bitmap);
}
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
......@@ -263,6 +280,20 @@ GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
return NotImplemented;
}
/* FIXME: test this function for non-bitmap types */
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
{
if(!image || !format)
return InvalidParameter;
if(image->type != ImageTypeBitmap)
*format = PixelFormat24bppRGB;
else
*format = ((GpBitmap*) image)->format;
return Ok;
}
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
{
static int calls;
......
......@@ -172,6 +172,7 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage*);
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage*,GpRectF*,GpUnit*);
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage*,UINT*);
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage*,REAL*);
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage*,PixelFormat*);
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage*,GUID*);
GpStatus WINGDIPAPI GdipGetImageType(GpImage*,ImageType*);
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage*,REAL*);
......
......@@ -22,4 +22,30 @@
typedef DWORD ARGB;
typedef INT PixelFormat;
#define PixelFormatIndexed 0x00010000
#define PixelFormatGDI 0x00020000
#define PixelFormatAlpha 0x00040000
#define PixelFormatPAlpha 0x00080000
#define PixelFormatExtended 0x00100000
#define PixelFormatCanonical 0x00200000
#define PixelFormatUndefined 0
#define PixelFormatDontCare 0
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
#define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
#define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
#define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
#define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
#define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
#define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
#define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
#define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
#define PixelFormatMax 15
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment