From abfe28ce44daf5a6b0c70cdf107a80f2f43cbb27 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 8 May 2010 12:01:07 -0500 Subject: [PATCH] gdiplus: Implement GdipCreateHICONFromBitmap. --- dlls/gdiplus/image.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 49 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 56b79e1..bc13ad9 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1804,9 +1804,56 @@ GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphic GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hicon) { - FIXME("(%p, %p)\n", bitmap, hicon); + GpStatus stat; + BitmapData lockeddata; + ULONG andstride, xorstride, bitssize; + LPBYTE andbits, xorbits, androw, xorrow, srcrow; + UINT x, y; - return NotImplemented; + TRACE("(%p, %p)\n", bitmap, hicon); + + if (!bitmap || !hicon) + return InvalidParameter; + + stat = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, + PixelFormat32bppPARGB, &lockeddata); + if (stat == Ok) + { + andstride = ((lockeddata.Width+31)/32)*4; + xorstride = lockeddata.Width*4; + bitssize = (andstride + xorstride) * lockeddata.Height; + + andbits = GdipAlloc(bitssize); + + if (andbits) + { + xorbits = andbits + andstride * lockeddata.Height; + + for (y=0; y= 128) + androw[x/8] |= 1 << (7-x%8); + + xorrow = xorbits + xorstride * y; + memcpy(xorrow, srcrow, xorstride); + } + + *hicon = CreateIcon(NULL, lockeddata.Width, lockeddata.Height, 1, 32, + andbits, xorbits); + + GdipFree(andbits); + } + else + stat = OutOfMemory; + + GdipBitmapUnlockBits(bitmap, &lockeddata); + } + + return stat; } GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp) -- 1.6.3.3