From b2ebf709ffa859bc4515bf0c12ba4c347ce3a293 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 10 Jul 2008 15:39:29 +0100 Subject: [PATCH] gdiplus: Partial implementation of GdipCreateBitmapFromGdiDib. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/image.c | 41 +++++++++++++++++++++++++++++++++++++++ include/gdiplusflat.h | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 318ec530b39..b1c784de949 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -73,7 +73,7 @@ @ stub GdipCreateBitmapFromDirectDrawSurface @ stdcall GdipCreateBitmapFromFile(wstr ptr) @ stdcall GdipCreateBitmapFromFileICM(wstr ptr) -@ stub GdipCreateBitmapFromGdiDib +@ stdcall GdipCreateBitmapFromGdiDib(ptr ptr ptr) @ stdcall GdipCreateBitmapFromGraphics(long long ptr ptr) @ stdcall GdipCreateBitmapFromHBITMAP(long long ptr) @ stub GdipCreateBitmapFromHICON diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 8fd452a304d..d2ce0747bbd 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -270,6 +270,47 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename, return stat; } +GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO* info, + VOID *bits, GpBitmap **bitmap) +{ + DWORD height, stride; + PixelFormat format; + + FIXME("(%p, %p, %p) - partially implemented\n", info, bits, bitmap); + + height = abs(info->bmiHeader.biHeight); + stride = ((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) >> 3) & ~3; + + if(info->bmiHeader.biHeight > 0) /* bottom-up */ + { + bits = (BYTE*)bits + (height - 1) * stride; + stride = -stride; + } + + switch(info->bmiHeader.biBitCount) { + case 1: + format = PixelFormat1bppIndexed; + break; + case 4: + format = PixelFormat4bppIndexed; + break; + case 8: + format = PixelFormat8bppIndexed; + break; + case 24: + format = PixelFormat24bppRGB; + break; + default: + FIXME("don't know how to handle %d bpp\n", info->bmiHeader.biBitCount); + *bitmap = NULL; + return InvalidParameter; + } + + return GdipCreateBitmapFromScan0(info->bmiHeader.biWidth, height, stride, format, + bits, bitmap); + +} + /* FIXME: no icm */ GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM(GDIPCONST WCHAR* filename, GpBitmap **bitmap) diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index ad40a67dd57..25b6f5fcee0 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -332,6 +332,7 @@ GpStatus WINGDIPAPI GdipConvertToEmfPlusToFile(const GpGraphics*,GpMetafile*,INT GpStatus WINGDIPAPI GdipConvertToEmfPlusToStream(const GpGraphics*,GpMetafile*,INT*,IStream*,EmfType,const WCHAR*,GpMetafile**); GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR*,GpBitmap**); GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM(GDIPCONST WCHAR*,GpBitmap**); +GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO*,VOID*,GpBitmap**); GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT,INT,GpGraphics*,GpBitmap**); GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT,INT,INT,PixelFormat,BYTE*, GpBitmap**);