return himl && himl->magic == IMAGELIST_MAGIC;
}
+static inline void imagelist_point_from_index( HIMAGELIST himl, UINT index, LPPOINT pt )
+{
+ pt->x = index * himl->cx;
+ pt->y = 0;
+}
/*************************************************************************
* IMAGELIST_InternalExpandBitmaps [Internal]
{
HDC hdcBitmap;
INT nFirstIndex, nImageCount;
- INT nStartX;
BITMAP bmp;
HBITMAP hOldBitmap;
+ POINT pt;
TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask);
if (!is_valid(himl))
IMAGELIST_InternalExpandBitmaps (himl, nImageCount, bmp.bmWidth, bmp.bmHeight);
- nStartX = himl->cCurImage * himl->cx;
+ imagelist_point_from_index( himl, himl->cCurImage, &pt );
hdcBitmap = CreateCompatibleDC(0);
/* Copy result to the imagelist
*/
- BitBlt (himl->hdcImage, nStartX, 0, bmp.bmWidth, bmp.bmHeight,
+ BitBlt (himl->hdcImage, pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
hdcBitmap, 0, 0, SRCCOPY);
if(himl->hbmMask)
hOldBitmapTemp = SelectObject(hdcTemp, hbmMask);
BitBlt (himl->hdcMask,
- nStartX, 0, bmp.bmWidth, bmp.bmHeight,
+ pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
hdcTemp,
0, 0,
SRCCOPY);
/* Remove the background from the image
*/
BitBlt (himl->hdcImage,
- nStartX, 0, bmp.bmWidth, bmp.bmHeight,
+ pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
himl->hdcMask,
- nStartX, 0,
+ pt.x, pt.y,
0x220326); /* NOTSRCAND */
}
HBITMAP hOldBitmap;
HBITMAP hMaskBitmap=0;
COLORREF bkColor;
+ POINT pt;
TRACE("himl=%p hbitmap=%p clrmask=%x\n", himl, hBitmap, clrMask);
if (!is_valid(himl))
0x220326); /* NOTSRCAND */
/* Copy result to the imagelist
*/
+ imagelist_point_from_index( himl, nIndex, &pt );
BitBlt (himl->hdcImage,
- nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
+ pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
hdcBitmap,
0, 0,
SRCCOPY);
ImageList_Copy (HIMAGELIST himlDst, INT iDst, HIMAGELIST himlSrc,
INT iSrc, UINT uFlags)
{
+ POINT ptSrc, ptDst;
+
TRACE("himlDst=%p iDst=%d himlSrc=%p iSrc=%d\n", himlDst, iDst, himlSrc, iSrc);
if (!is_valid(himlSrc) || !is_valid(himlDst))
if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage))
return FALSE;
+ imagelist_point_from_index( himlDst, iDst, &ptDst );
+ imagelist_point_from_index( himlSrc, iSrc, &ptSrc );
+
if (uFlags & ILCF_SWAP) {
/* swap */
HDC hdcBmp;
HBITMAP hbmTempImage, hbmTempMask;
hdcBmp = CreateCompatibleDC (0);
-
+
/* create temporary bitmaps */
hbmTempImage = CreateBitmap (himlSrc->cx, himlSrc->cy, 1,
himlSrc->uBitsPixel, NULL);
/* image */
SelectObject (hdcBmp, hbmTempImage);
StretchBlt (hdcBmp, 0, 0, himlSrc->cx, himlSrc->cy,
- himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+ himlDst->hdcImage, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
SRCCOPY);
/* mask */
SelectObject (hdcBmp, hbmTempMask);
StretchBlt (hdcBmp, 0, 0, himlSrc->cx, himlSrc->cy,
- himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
+ himlDst->hdcMask, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
SRCCOPY);
/* copy (and stretch) source to destination */
/* image */
- StretchBlt (himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
- himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ StretchBlt (himlDst->hdcImage, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
+ himlSrc->hdcImage, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
SRCCOPY);
/* mask */
- StretchBlt (himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
- himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ StretchBlt (himlDst->hdcMask, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
+ himlSrc->hdcMask, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
SRCCOPY);
/* copy (without stretching) temporary bitmaps to source (restore) */
/* mask */
- BitBlt (himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ BitBlt (himlSrc->hdcMask, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
hdcBmp, 0, 0, SRCCOPY);
/* image */
- BitBlt (himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ BitBlt (himlSrc->hdcImage, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
hdcBmp, 0, 0, SRCCOPY);
/* delete temporary bitmaps */
DeleteObject (hbmTempMask);
}
else {
/* copy image */
- StretchBlt (himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
- himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ StretchBlt (himlDst->hdcImage, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
+ himlSrc->hdcImage, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
SRCCOPY);
/* copy mask */
- StretchBlt (himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy,
- himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy,
+ StretchBlt (himlDst->hdcMask, ptDst.x, ptDst.y, himlDst->cx, himlDst->cy,
+ himlSrc->hdcMask, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy,
SRCCOPY);
}
BOOL WINAPI
ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
{
- INT cx, cy, lx, ly, nOvlIdx;
+ INT cx, cy, nOvlIdx;
DWORD fState, dwRop;
UINT fStyle;
COLORREF oldImageBk, oldImageFg;
HBITMAP hImageBmp, hOldImageBmp, hBlendMaskBmp;
BOOL bIsTransparent, bBlend, bResult = FALSE, bMask;
HIMAGELIST himl;
+ POINT pt;
if (!pimldp || !(himl = pimldp->himl)) return FALSE;
if (!is_valid(himl)) return FALSE;
if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE;
- lx = himl->cx * pimldp->i + pimldp->xBitmap;
- ly = pimldp->yBitmap;
+ imagelist_point_from_index( himl, pimldp->i, &pt );
+ pt.x += pimldp->xBitmap;
+ pt.y += pimldp->yBitmap;
fState = pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS) ? ILS_NORMAL : pimldp->fState;
fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK;
HBRUSH hOldBrush;
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (GetTextColor(pimldp->hdcDst)));
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
- BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCPAINT);
+ BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, pt.x, pt.y, SRCPAINT);
DeleteObject (SelectObject (hImageDC, hOldBrush));
if( bIsTransparent )
{
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
- BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND );
- BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT );
+ BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, pt.x, pt.y, SRCAND );
+ BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, pt.x, pt.y, SRCPAINT );
DeleteObject (SelectObject (hImageDC, hOldBrush));
}
-
+
/* Time for blending, if required */
if (bBlend) {
HBRUSH hBlendBrush, hOldBrush;
/* Modify the blend mask if an Image Mask exist */
if(himl->hbmMask) {
- BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, lx, ly, 0x220326); /* NOTSRCAND */
+ BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, pt.x, pt.y, 0x220326); /* NOTSRCAND */
BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, NOTSRCCOPY);
}
DeleteObject(SelectObject(hImageDC, hOldBrush));
SelectObject(hBlendMaskDC, hOldBitmap);
}
-
- /* Now do the overlay image, if any */
+
+ /* Now do the overlay image, if any */
nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
if ( (nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) {
- nOvlIdx = himl->nOvlIdx[nOvlIdx - 1];
- if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) {
- const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap;
+ nOvlIdx = himl->nOvlIdx[nOvlIdx - 1];
+ if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) {
+ const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap;
if (himl->hbmMask && !(fStyle & ILD_IMAGE))
- BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, ly, SRCAND);
- BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, ly, SRCPAINT);
+ BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, pt.x, SRCAND);
+ BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, pt.y, SRCPAINT);
}
}
if (himl->hbmMask && bIsTransparent ) {
COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) );
COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff ));
- BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND);
+ BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, pt.x, pt.y, SRCAND);
SetBkColor(pimldp->hdcDst, oldDstBk);
SetTextColor(pimldp->hdcDst, oldDstFg);
dwRop = SRCPAINT;
BOOL WINAPI
ImageList_GetImageInfo (HIMAGELIST himl, INT i, IMAGEINFO *pImageInfo)
{
+ POINT pt;
+
if (!is_valid(himl) || (pImageInfo == NULL))
return FALSE;
if ((i < 0) || (i >= himl->cCurImage))
pImageInfo->hbmImage = himl->hbmImage;
pImageInfo->hbmMask = himl->hbmMask;
- pImageInfo->rcImage.top = 0;
- pImageInfo->rcImage.bottom = himl->cy;
- pImageInfo->rcImage.left = i * himl->cx;
- pImageInfo->rcImage.right = (i+1) * himl->cx;
+ imagelist_point_from_index( himl, i, &pt );
+ pImageInfo->rcImage.top = pt.y;
+ pImageInfo->rcImage.bottom = pt.y + himl->cy;
+ pImageInfo->rcImage.left = pt.x;
+ pImageInfo->rcImage.right = pt.x + himl->cx;
return TRUE;
}
BOOL WINAPI
ImageList_GetImageRect (HIMAGELIST himl, INT i, LPRECT lpRect)
{
+ POINT pt;
+
if (!is_valid(himl) || (lpRect == NULL))
return FALSE;
if ((i < 0) || (i >= himl->cCurImage))
return FALSE;
- lpRect->left = i * himl->cx;
- lpRect->top = 0;
- lpRect->right = lpRect->left + himl->cx;
- lpRect->bottom = himl->cy;
+ imagelist_point_from_index( himl, i, &pt );
+ lpRect->left = pt.x;
+ lpRect->top = pt.y;
+ lpRect->right = pt.x + himl->cx;
+ lpRect->bottom = pt.y + himl->cy;
return TRUE;
}