Mike McCormack : imagelist:
Move Nx1 assumptions about bitmaps dimensions into a single function.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Nov 1 07:09:01 CST 2006
Module: wine
Branch: master
Commit: 83a66a981f6c8f46072c466266a54f4e265bdf85
URL: http://source.winehq.org/git/wine.git/?a=commit;h=83a66a981f6c8f46072c466266a54f4e265bdf85
Author: Mike McCormack <mike at codeweavers.com>
Date: Wed Nov 1 15:45:11 2006 +0900
imagelist: Move Nx1 assumptions about bitmaps dimensions into a single function.
---
dlls/comctl32/imagelist.c | 41 ++++++++++++++++++++++++++++-------------
1 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index eac188e..ae24e06 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -22,14 +22,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTE
- *
+ *
* This code was audited for completeness against the documented features
* of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun.
- *
+ *
* Unless otherwise noted, we believe this code to be complete, as per
* the specification mentioned above.
* If you discover missing features, or bugs, please note them below.
- *
+ *
* TODO:
* - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE
* - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE, ILS_ALPHA
@@ -90,6 +90,12 @@ static inline void imagelist_point_from_
pt->y = 0;
}
+static inline void imagelist_get_bitmap_size( HIMAGELIST himl, UINT count, UINT cy, SIZE *sz )
+{
+ sz->cx = count * himl->cx;
+ sz->cy = cy;
+}
+
/*************************************************************************
* IMAGELIST_InternalExpandBitmaps [Internal]
*
@@ -111,6 +117,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGEL
HDC hdcBitmap;
HBITMAP hbmNewBitmap, hbmNull;
INT nNewWidth, nNewCount;
+ SIZE sz;
if ((himl->cCurImage + nImageCount <= himl->cMaxImage)
&& (himl->cy >= cy))
@@ -128,10 +135,12 @@ IMAGELIST_InternalExpandBitmaps (HIMAGEL
if (hbmNewBitmap == 0)
ERR("creating new image bitmap (x=%d y=%d)!\n", nNewWidth, cy);
- if(himl->cCurImage)
+ imagelist_get_bitmap_size(himl, nNewCount, cy, &sz);
+
+ if (himl->cCurImage)
{
hbmNull = SelectObject (hdcBitmap, hbmNewBitmap);
- BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy,
+ BitBlt (hdcBitmap, 0, 0, sz.cx, sz.cy,
himl->hdcImage, 0, 0, SRCCOPY);
SelectObject (hdcBitmap, hbmNull);
}
@@ -149,7 +158,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGEL
if(himl->cCurImage)
{
hbmNull = SelectObject (hdcBitmap, hbmNewBitmap);
- BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy,
+ BitBlt (hdcBitmap, 0, 0, sz.cx, sz.cy,
himl->hdcMask, 0, 0, SRCCOPY);
SelectObject (hdcBitmap, hbmNull);
}
@@ -617,9 +626,10 @@ ImageList_Create (INT cx, INT cy, UINT f
himl->hbmImage = 0;
if ((himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
- himl->hbmMask =
- CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
- 1, 1, NULL);
+ SIZE sz;
+
+ imagelist_get_bitmap_size(himl, himl->cMaxImage, himl->cy, &sz);
+ himl->hbmMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL);
if (himl->hbmMask == 0) {
ERR("Error creating mask bitmap!\n");
goto cleanup;
@@ -1275,11 +1285,14 @@ ImageList_Duplicate (HIMAGELIST himlSrc)
if (himlDst)
{
- BitBlt (himlDst->hdcImage, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy,
+ SIZE sz;
+
+ imagelist_get_bitmap_size(himlSrc, himlSrc->cCurImage, himlSrc->cy, &sz);
+ BitBlt (himlDst->hdcImage, 0, 0, sz.cx, sz.cy,
himlSrc->hdcImage, 0, 0, SRCCOPY);
if (himlDst->hbmMask)
- BitBlt (himlDst->hdcMask, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy,
+ BitBlt (himlDst->hdcMask, 0, 0, sz.cx, sz.cy,
himlSrc->hdcMask, 0, 0, SRCCOPY);
himlDst->cCurImage = himlSrc->cCurImage;
@@ -2079,8 +2092,10 @@ ImageList_Remove (HIMAGELIST himl, INT i
himl->hbmImage = hbmNewImage;
if (himl->hbmMask) {
- hbmNewMask = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy,
- 1, 1, NULL);
+ SIZE sz;
+
+ imagelist_get_bitmap_size(himl, himl->cMaxImage, himl->cy, &sz);
+ hbmNewMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL);
SelectObject (himl->hdcMask, hbmNewMask);
DeleteObject (himl->hbmMask);
himl->hbmMask = hbmNewMask;
More information about the wine-cvs
mailing list