Commit 83a66a98 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

imagelist: Move Nx1 assumptions about bitmaps dimensions into a single function.

parent 14dda0f7
...@@ -90,6 +90,12 @@ static inline void imagelist_point_from_index( HIMAGELIST himl, UINT index, LPPO ...@@ -90,6 +90,12 @@ static inline void imagelist_point_from_index( HIMAGELIST himl, UINT index, LPPO
pt->y = 0; 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] * IMAGELIST_InternalExpandBitmaps [Internal]
* *
...@@ -111,6 +117,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c ...@@ -111,6 +117,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c
HDC hdcBitmap; HDC hdcBitmap;
HBITMAP hbmNewBitmap, hbmNull; HBITMAP hbmNewBitmap, hbmNull;
INT nNewWidth, nNewCount; INT nNewWidth, nNewCount;
SIZE sz;
if ((himl->cCurImage + nImageCount <= himl->cMaxImage) if ((himl->cCurImage + nImageCount <= himl->cMaxImage)
&& (himl->cy >= cy)) && (himl->cy >= cy))
...@@ -128,10 +135,12 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c ...@@ -128,10 +135,12 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c
if (hbmNewBitmap == 0) if (hbmNewBitmap == 0)
ERR("creating new image bitmap (x=%d y=%d)!\n", nNewWidth, cy); 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); 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); himl->hdcImage, 0, 0, SRCCOPY);
SelectObject (hdcBitmap, hbmNull); SelectObject (hdcBitmap, hbmNull);
} }
...@@ -149,7 +158,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c ...@@ -149,7 +158,7 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT c
if(himl->cCurImage) if(himl->cCurImage)
{ {
hbmNull = SelectObject (hdcBitmap, hbmNewBitmap); 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); himl->hdcMask, 0, 0, SRCCOPY);
SelectObject (hdcBitmap, hbmNull); SelectObject (hdcBitmap, hbmNull);
} }
...@@ -617,9 +626,10 @@ ImageList_Create (INT cx, INT cy, UINT flags, ...@@ -617,9 +626,10 @@ ImageList_Create (INT cx, INT cy, UINT flags,
himl->hbmImage = 0; himl->hbmImage = 0;
if ((himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) { if ((himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
himl->hbmMask = SIZE sz;
CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
1, 1, NULL); imagelist_get_bitmap_size(himl, himl->cMaxImage, himl->cy, &sz);
himl->hbmMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL);
if (himl->hbmMask == 0) { if (himl->hbmMask == 0) {
ERR("Error creating mask bitmap!\n"); ERR("Error creating mask bitmap!\n");
goto cleanup; goto cleanup;
...@@ -1275,11 +1285,14 @@ ImageList_Duplicate (HIMAGELIST himlSrc) ...@@ -1275,11 +1285,14 @@ ImageList_Duplicate (HIMAGELIST himlSrc)
if (himlDst) 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); himlSrc->hdcImage, 0, 0, SRCCOPY);
if (himlDst->hbmMask) 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); himlSrc->hdcMask, 0, 0, SRCCOPY);
himlDst->cCurImage = himlSrc->cCurImage; himlDst->cCurImage = himlSrc->cCurImage;
...@@ -2079,8 +2092,10 @@ ImageList_Remove (HIMAGELIST himl, INT i) ...@@ -2079,8 +2092,10 @@ ImageList_Remove (HIMAGELIST himl, INT i)
himl->hbmImage = hbmNewImage; himl->hbmImage = hbmNewImage;
if (himl->hbmMask) { if (himl->hbmMask) {
hbmNewMask = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, SIZE sz;
1, 1, NULL);
imagelist_get_bitmap_size(himl, himl->cMaxImage, himl->cy, &sz);
hbmNewMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL);
SelectObject (himl->hdcMask, hbmNewMask); SelectObject (himl->hdcMask, hbmNewMask);
DeleteObject (himl->hbmMask); DeleteObject (himl->hbmMask);
himl->hbmMask = hbmNewMask; himl->hbmMask = hbmNewMask;
......
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