Changeset 496 for trunk/src/comctl32/imagelist.c
- Timestamp:
- Aug 14, 1999, 6:13:16 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/imagelist.c
r295 r496 1 /* $Id: imagelist.c,v 1. 5 1999-07-12 15:58:47cbratschi Exp $ */1 /* $Id: imagelist.c,v 1.6 1999-08-14 16:13:11 cbratschi Exp $ */ 2 2 /* 3 3 * ImageList implementation … … 76 76 * This function can NOT be used to reduce the number of images. 77 77 */ 78 79 78 static VOID 80 79 IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount) … … 142 141 */ 143 142 143 144 /************************************************************************* 145 * IMAGELIST_InternalDraw [Internal] 146 * 147 * Draws the image in the ImageList (without the mask) 148 * 149 * PARAMS 150 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 151 * cx [I] the width of the image to display 152 * cy............[I] the height of the image to display 153 * 154 * RETURNS 155 * nothing 156 * 157 * NOTES 158 * This functions is used by ImageList_DrawIndirect, when it is 159 * required to draw only the Image (without the mask) to the screen. 160 * 161 * Blending and Overlays styles are accomplised by another function 162 */ 163 static VOID 164 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 165 { 166 HDC hImageDC; 167 HBITMAP hOldBitmap; 168 hImageDC = CreateCompatibleDC(0); 169 hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage); 170 BitBlt(pimldp->hdcDst, 171 pimldp->x, pimldp->y, cx, cy, 172 hImageDC, 173 pimldp->himl->cx * pimldp->i, 0, 174 SRCCOPY); 175 176 SelectObject(hImageDC, hOldBitmap); 177 DeleteDC(hImageDC); 178 } 179 180 181 /************************************************************************* 182 * IMAGELIST_InternalDrawMask [Internal] 183 * 184 * Draws the image in the ImageList witht the mask 185 * 186 * PARAMS 187 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 188 * cx [I] the width of the image to display 189 * cy............[I] the height of the image to display 190 * 191 * RETURNS 192 * nothing 193 * 194 * NOTES 195 * This functions is used by ImageList_DrawIndirect, when it is 196 * required to draw the Image with the mask to the screen. 197 * 198 * Blending and Overlays styles are accomplised by another function. 199 */ 200 static VOID 201 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 202 { 203 HDC hMaskDC, hImageDC; 204 BOOL bUseCustomBackground, bBlendFlag; 205 HBRUSH hBrush, hOldBrush; 206 HBITMAP hOldBitmapImage, hOldBitmapMask; 207 HIMAGELIST himlLocal = pimldp->himl; 208 209 bUseCustomBackground = (himlLocal->clrBk != CLR_NONE); 210 bBlendFlag = (pimldp->fStyle & ILD_BLEND50 ) 211 || (pimldp->fStyle & ILD_BLEND25); 212 213 hImageDC = CreateCompatibleDC(0); 214 hMaskDC = CreateCompatibleDC(0); 215 216 hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage); 217 hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask); 218 /* Draw the Background for the appropriate Styles 219 */ 220 if( bUseCustomBackground && (pimldp->fStyle == ILD_NORMAL 221 || pimldp->fStyle & ILD_IMAGE 222 || bBlendFlag)) 223 { 224 hBrush = CreateSolidBrush (himlLocal->clrBk); 225 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 226 PatBlt (pimldp->hdcDst, 227 pimldp->x, pimldp->y, cx, cy, 228 PATCOPY); 229 230 DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush)); 231 } 232 233 /* Draw Image Transparently over the current background 234 */ 235 if(pimldp->fStyle == ILD_NORMAL 236 || pimldp->fStyle & ILD_TRANSPARENT 237 || ((pimldp->fStyle & ILD_IMAGE) && bUseCustomBackground) 238 || bBlendFlag) 239 { 240 BitBlt(pimldp->hdcDst, 241 pimldp->x, pimldp->y, cx, cy, 242 hMaskDC, 243 himlLocal->cx * pimldp->i, 0, 244 SRCAND); 245 246 BitBlt(pimldp->hdcDst, 247 pimldp->x, pimldp->y, cx, cy, 248 hImageDC, 249 himlLocal->cx * pimldp->i, 0, 250 SRCPAINT); 251 } 252 /* Draw the image when no Background is specified 253 */ 254 else if(pimldp->fStyle & ILD_IMAGE && !bUseCustomBackground) 255 { 256 BitBlt(pimldp->hdcDst, 257 pimldp->x, pimldp->y, cx, cy, 258 hImageDC, 259 himlLocal->cx * pimldp->i, 0, 260 SRCCOPY); 261 } 262 /* Draw the mask with or without a background 263 */ 264 else if(pimldp->fStyle & ILD_MASK) 265 { 266 BitBlt(pimldp->hdcDst, 267 pimldp->x, pimldp->y, cx, cy, 268 hMaskDC, 269 himlLocal->cx * pimldp->i, 0, 270 bUseCustomBackground ? SRCCOPY : SRCAND); 271 } 272 SelectObject(hImageDC, hOldBitmapImage); 273 SelectObject(hMaskDC, hOldBitmapMask); 274 DeleteDC(hImageDC); 275 DeleteDC(hMaskDC); 276 } 277 278 /************************************************************************* 279 * IMAGELIST_InternalDrawBlend [Internal] 280 * 281 * Draws the Blend over the current image 282 * 283 * PARAMS 284 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 285 * cx [I] the width of the image to display 286 * cy............[I] the height of the image to display 287 * 288 * RETURNS 289 * nothing 290 * 291 * NOTES 292 * This functions is used by ImageList_DrawIndirect, when it is 293 * required to add the blend to the current image. 294 * 295 */ 296 static VOID 297 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 298 { 299 300 HDC hBlendMaskDC,hMaskDC; 301 HBRUSH hBlendColorBrush, hBlendBrush, hOldBrush; 302 HBITMAP hBlendMaskBitmap, hOldBitmap; 303 COLORREF clrBlend, OldTextColor, OldBkColor; 304 HIMAGELIST himlLocal = pimldp->himl; 305 306 clrBlend = GetSysColor (COLOR_HIGHLIGHT); 307 if (!(pimldp->rgbFg == CLR_DEFAULT)) 308 { 309 clrBlend = pimldp->rgbFg; 310 } 311 /* Create the blend Mask 312 */ 313 hBlendMaskDC = CreateCompatibleDC(0); 314 hBlendBrush = pimldp->fStyle & ILD_BLEND50 ? 315 himlLocal->hbrBlend50 : himlLocal->hbrBlend25; 316 317 hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL); 318 hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap); 319 320 hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush); 321 PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY); 322 SelectObject(hBlendMaskDC, hOldBrush); 323 324 /* Modify the blend mask if an Image Mask exist 325 */ 326 if(pimldp->himl->hbmMask != 0) 327 { 328 HBITMAP hOldMaskBitmap; 329 hMaskDC = CreateCompatibleDC(0); 330 hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask); 331 332 BitBlt(hBlendMaskDC, 333 0,0, cx, cy, 334 hMaskDC, 335 himlLocal->cx * pimldp->i,0, 336 0x220326); /* NOTSRCAND */ 337 338 BitBlt(hBlendMaskDC, 339 0,0, cx, cy, 340 hBlendMaskDC, 341 0,0, 342 NOTSRCCOPY); 343 344 SelectObject(hMaskDC, hOldMaskBitmap); 345 DeleteDC(hMaskDC); 346 347 } 348 /* Apply blend to the current image given the BlendMask 349 */ 350 OldTextColor = SetTextColor(pimldp->hdcDst, 0); 351 OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255)); 352 hBlendColorBrush = CreateSolidBrush(clrBlend); 353 hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush); 354 355 BitBlt (pimldp->hdcDst, 356 pimldp->x, pimldp->y, cx, cy, 357 hBlendMaskDC, 358 0, 0, 359 0xB8074A); /* PSDPxax */ 360 361 SelectObject(pimldp->hdcDst, hOldBrush); 362 SetTextColor(pimldp->hdcDst, OldTextColor); 363 SetBkColor(pimldp->hdcDst, OldBkColor); 364 SelectObject(hBlendMaskDC, hOldBitmap); 365 DeleteDC(hBlendMaskDC); 366 DeleteObject(hBlendMaskBitmap); 367 DeleteObject(hBlendColorBrush); 368 } 369 370 /************************************************************************* 371 * IMAGELIST_InternalDrawOverlay [Internal] 372 * 373 * Draws the overlay image 374 * 375 * PARAMS 376 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 377 * cx [I] the width of the image to display 378 * cy............[I] the height of the image to display 379 * 380 * RETURNS 381 * nothing 382 * 383 * NOTES 384 * This functions is used by ImageList_DrawIndirect, when it is 385 * required to draw the overlay 386 * 387 * 388 */ 389 static VOID 390 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 391 { 392 INT nOvlIdx; 393 HDC hImageDC; 394 HBITMAP hOldBitmap; 395 396 nOvlIdx = (pimldp->fStyle & 0x0700) >> 8; 397 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) 398 { 399 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 400 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) 401 { 402 hImageDC = CreateCompatibleDC(0); 403 if (pimldp->himl->hbmMask) 404 { 405 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 406 pimldp->himl->hbmMask); 407 408 BitBlt (pimldp->hdcDst, 409 pimldp->x, pimldp->y, cx, cy, 410 hImageDC, pimldp->himl->cx * nOvlIdx, 0, 411 SRCAND); 412 413 SelectObject(hImageDC, hOldBitmap); 414 } 415 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 416 pimldp->himl->hbmImage); 417 418 BitBlt (pimldp->hdcDst, 419 pimldp->x, pimldp->y, cx, cy, 420 hImageDC, 421 pimldp->himl->cx * nOvlIdx, 0, 422 SRCPAINT); 423 424 SelectObject(hImageDC, hOldBitmap); 425 DeleteDC(hImageDC); 426 } 427 } 428 } 429 430 431 432 433 144 434 INT WINAPI 145 435 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) 146 436 { 147 HDC hdcSrc, hdcDst; 148 INT nFirstIndex, nImageCount; 149 INT nStartX; 150 BITMAP bmp; 437 HDC hdcImage, hdcBitmap; 438 INT nFirstIndex, nImageCount; 439 INT nStartX; 440 BITMAP bmp; 441 HBITMAP hOldBitmapImage, hOldBitmap; 151 442 152 443 if (!himl || !hbmImage) 153 444 return -1; 154 445 155 446 GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); … … 161 452 nStartX = himl->cCurImage * himl->cx; 162 453 163 hdcSrc = CreateCompatibleDC (0); 164 hdcDst = CreateCompatibleDC (0); 165 166 /* copy image bitmap */ 167 SelectObject (hdcDst, himl->hbmImage); 168 SelectObject (hdcSrc, hbmImage); 169 BitBlt (hdcDst, himl->cCurImage * himl->cx, 0, 170 bmp.bmWidth, himl->cy, hdcSrc, 0, 0, SRCCOPY); 171 172 if (himl->hbmMask) { 173 if (hbmMask) { 174 /* copy mask bitmap */ 175 SelectObject (hdcDst, himl->hbmMask); 176 SelectObject (hdcSrc, hbmMask); 177 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 178 hdcSrc, 0, 0, SRCCOPY); 179 } 180 else { 181 /* copy monochrome image to the mask bitmap */ 182 SelectObject (hdcDst, himl->hbmMask); 183 SelectObject (hdcSrc, hbmImage); 184 SetBkColor (hdcSrc, GetNearestColor (hdcSrc, 185 GetPixel (hdcSrc, 0, 0))); 186 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 187 hdcSrc, nStartX, 0, SRCCOPY); 188 } 189 } 190 191 DeleteDC (hdcSrc); 192 DeleteDC (hdcDst); 454 hdcImage = CreateCompatibleDC(0); 455 hdcBitmap = CreateCompatibleDC(0); 456 457 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); 458 hOldBitmap = SelectObject(hdcBitmap, hbmImage); 459 460 /* Copy result to the imagelist 461 */ 462 BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, himl->cy, 463 hdcBitmap, 0, 0, SRCCOPY); 464 465 if(himl->hbmMask) 466 { 467 HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp; 468 469 hdcMask = CreateCompatibleDC (0); 470 hdcTemp = CreateCompatibleDC(0); 471 hOldBitmapMask = (HBITMAP) SelectObject(hdcMask, himl->hbmMask); 472 hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask); 473 474 BitBlt (hdcMask, 475 nStartX, 0, bmp.bmWidth, himl->cy, 476 hdcTemp, 477 0, 0, 478 SRCCOPY); 479 480 SelectObject(hdcTemp, hOldBitmapTemp); 481 DeleteDC(hdcTemp); 482 483 /* Remove the background from the image 484 */ 485 BitBlt (hdcImage, 486 nStartX, 0, bmp.bmWidth, himl->cy, 487 hdcMask, 488 nStartX, 0, 489 0x220326); /* NOTSRCAND */ 490 491 SelectObject(hdcMask, hOldBitmapMask); 492 DeleteDC(hdcMask); 493 } 494 495 SelectObject(hdcImage, hOldBitmapImage); 496 SelectObject(hdcBitmap, hOldBitmap); 497 DeleteDC(hdcImage); 498 DeleteDC(hdcBitmap); 193 499 194 500 nFirstIndex = himl->cCurImage; … … 240 546 { 241 547 HDC hdcImage, hdcMask, hdcBitmap; 242 INT nIndex, nImageCount ;548 INT nIndex, nImageCount, nMaskXOffset=0; 243 549 BITMAP bmp; 550 HBITMAP hOldBitmap, hOldBitmapMask, hOldBitmapImage; 551 HBITMAP hMaskBitmap=0; 552 COLORREF bkColor; 244 553 245 554 if (himl == NULL) … … 252 561 253 562 if (himl->cCurImage + nImageCount >= himl->cMaxImage) 563 { 254 564 IMAGELIST_InternalExpandBitmaps (himl, nImageCount); 565 } 255 566 256 567 nIndex = himl->cCurImage; 257 568 himl->cCurImage += nImageCount; 258 569 259 hdcImage = CreateCompatibleDC (0); 260 hdcBitmap = CreateCompatibleDC (0); 261 262 SelectObject (hdcBitmap, hBitmap); 263 SelectObject (hdcImage, himl->hbmImage); 264 BitBlt (hdcImage, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 265 hdcBitmap, 0, 0, SRCCOPY); 266 267 if (himl->hbmMask) { 268 COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask : 269 GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0)); 270 271 /* create mask from image */ 272 hdcMask = CreateCompatibleDC (0); 273 SelectObject (hdcMask, himl->hbmMask); 274 275 /* create monochrome image to the mask bitmap */ 276 SetBkColor (hdcBitmap, bkColor); 277 BitBlt (hdcMask, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 278 hdcBitmap, 0, 0, SRCCOPY); 279 280 DeleteDC (hdcMask); 281 } 282 283 DeleteDC (hdcImage); 284 DeleteDC (hdcBitmap); 570 hdcMask = CreateCompatibleDC (0); 571 hdcImage = CreateCompatibleDC(0); 572 hdcBitmap = CreateCompatibleDC(0); 573 574 575 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); 576 hOldBitmap = SelectObject(hdcBitmap, hBitmap); 577 if(himl->hbmMask) 578 { 579 hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask); 580 nMaskXOffset = nIndex * himl->cx; 581 } 582 else 583 { 584 /* 585 Create a temp Mask so we can remove the background of 586 the Image (Windows does this even if there is no mask) 587 */ 588 hMaskBitmap = CreateBitmap(bmp.bmWidth, himl->cy, 1, 1, NULL); 589 hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap); 590 nMaskXOffset = 0; 591 } 592 /* create monochrome image to the mask bitmap */ 593 bkColor = (clrMask != CLR_DEFAULT) ? clrMask : 594 GetPixel (hdcBitmap, 0, 0); 595 SetBkColor (hdcBitmap, bkColor); 596 BitBlt (hdcMask, 597 nMaskXOffset, 0, bmp.bmWidth, himl->cy, 598 hdcBitmap, 0, 0, 599 SRCCOPY); 600 601 SetBkColor(hdcBitmap, RGB(255,255,255)); 602 /*Remove the background from the image 603 */ 604 /* 605 WINDOWS BUG ALERT!!!!!! 606 The statement below should not be done in common practice 607 but this is how ImageList_AddMasked works in Windows. 608 It overwrites the original bitmap passed, this was discovered 609 by using the same bitmap to itterated the different styles 610 on windows where it failed (BUT ImageList_Add is OK) 611 This is here in case some apps really on this bug 612 */ 613 BitBlt(hdcBitmap, 614 0, 0, bmp.bmWidth, himl->cy, 615 hdcMask, 616 nMaskXOffset, 0, 617 0x220326); /* NOTSRCAND */ 618 /* Copy result to the imagelist 619 */ 620 BitBlt (hdcImage, 621 nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 622 hdcBitmap, 623 0, 0, 624 SRCCOPY); 625 /* Clean up 626 */ 627 SelectObject(hdcMask,hOldBitmapMask); 628 SelectObject(hdcImage, hOldBitmapImage); 629 SelectObject(hdcBitmap, hOldBitmap); 630 DeleteDC(hdcMask); 631 DeleteDC(hdcImage); 632 DeleteDC(hdcBitmap); 633 if(!himl->hbmMask) 634 { 635 DeleteObject(hMaskBitmap); 636 } 285 637 286 638 return nIndex; … … 878 1230 ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) 879 1231 { 880 HIMAGELIST himlLocal;881 HDC hdcImageList, hdcTempImage;882 HBITMAP hbmTempImage;883 HBRUSH hBrush, hOldBrush;884 1232 INT cx, cy; 885 INT nOvlIdx; 886 COLORREF clrBlend; 887 BOOL bImage; /* draw image ? */ 888 BOOL bImageTrans; /* draw image transparent ? */ 889 BOOL bMask; /* draw mask ? */ 890 BOOL bMaskTrans; /* draw mask transparent ? */ 891 BOOL bBlend25; 892 BOOL bBlend50; 893 1233 /* 1234 Do some Error Checking 1235 */ 894 1236 if (pimldp == NULL) 895 1237 return FALSE; … … 900 1242 if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage)) 901 1243 return FALSE; 902 903 himlLocal = pimldp->himl; 904 905 cx = (pimldp->cx == 0) ? himlLocal->cx : pimldp->cx; 906 cy = (pimldp->cy == 0) ? himlLocal->cy : pimldp->cy; 907 908 /* ILD_NORMAL state */ 909 bImage = TRUE; 910 bImageTrans = FALSE; 911 bMask = FALSE; 912 bMaskTrans = FALSE; 913 bBlend25 = FALSE; 914 bBlend50 = FALSE; 915 if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask)) 1244 /* 1245 Get the Height and Width to display 1246 */ 1247 cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx; 1248 cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy; 1249 /* 1250 Draw the image 1251 */ 1252 if(pimldp->himl->hbmMask != 0) 916 1253 { 917 bImageTrans = TRUE; 918 bMask = TRUE; 919 bMaskTrans = TRUE; 920 } 921 922 /* ILD_IMAGE state (changes) */ 923 if (pimldp->fStyle & ILD_IMAGE) 1254 IMAGELIST_InternalDrawMask(pimldp, cx, cy); 1255 } 1256 else 924 1257 { 925 bMask = FALSE;926 bImage = TRUE;927 bImageTrans = FALSE;928 }929 930 /* ILD_MASK state (changes) */931 if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask))1258 IMAGELIST_InternalDraw(pimldp, cx, cy); 1259 } 1260 /* 1261 Apply the blend if needed to the Image 1262 */ 1263 if((pimldp->fStyle & ILD_BLEND50) 1264 || (pimldp->fStyle & ILD_BLEND25)) 932 1265 { 933 bMask = TRUE; 934 bMaskTrans = FALSE; 935 bImage = FALSE; 936 } 937 if ((pimldp->fStyle & ILD_TRANSPARENT) && (himlLocal->hbmMask)) 1266 IMAGELIST_InternalDrawBlend(pimldp, cx, cy); 1267 } 1268 /* 1269 Apply the Overlay if needed 1270 */ 1271 if (pimldp->fStyle & 0x0700) 938 1272 { 939 bMaskTrans = TRUE; 940 bImageTrans = TRUE; 941 } 942 if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask)) 943 bMaskTrans = TRUE; 944 945 if (pimldp->fStyle & ILD_BLEND50) 946 bBlend50 = TRUE; 947 else if (pimldp->fStyle & ILD_BLEND25) 948 bBlend25 = TRUE; 949 950 hdcImageList = CreateCompatibleDC (0); 951 952 if (bMask) 953 { 954 /* draw the mask */ 955 SelectObject (hdcImageList, himlLocal->hbmMask); 956 SetBkColor (hdcImageList, RGB(255, 255, 255)); 957 SetTextColor (hdcImageList, RGB(0, 0, 0)); 958 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 959 hdcImageList, himlLocal->cx * pimldp->i, 0, 960 bMaskTrans ? SRCAND : SRCCOPY); 961 } 962 963 if (bImage) 964 { 965 /* draw the image */ 966 SelectObject (hdcImageList, himlLocal->hbmImage); 967 968 if (!bImageTrans) 969 { 970 hBrush = CreateSolidBrush (himlLocal->clrBk); 971 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 972 PatBlt (pimldp->hdcDst, pimldp->x, pimldp->y, 973 cx, cy, PATCOPY); 974 DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush)); 975 } 976 977 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 978 hdcImageList, himlLocal->cx * pimldp->i, 0, SRCPAINT); 979 980 if (bBlend25 || bBlend50) 981 { 982 if (pimldp->rgbFg == CLR_DEFAULT) 983 clrBlend = GetSysColor (COLOR_HIGHLIGHT); 984 else 985 clrBlend = pimldp->rgbFg; 986 987 hdcTempImage = CreateCompatibleDC (0); 988 hbmTempImage = CreateBitmap (himlLocal->cx, himlLocal->cy, 989 1, himlLocal->uBitsPixel, NULL); 990 SelectObject (hdcTempImage, hbmTempImage); 991 992 993 /* mask */ 994 SelectObject (hdcTempImage, 995 bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25); 996 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY); 997 998 SelectObject (hdcImageList, himlLocal->hbmMask); 999 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 1000 himlLocal->cy, hdcImageList, 1001 pimldp->i * himlLocal->cx, 0, SRCPAINT); 1002 1003 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1004 hdcTempImage, 0, 0, SRCAND); 1005 1006 /* fill */ 1007 hBrush = CreateSolidBrush (clrBlend); 1008 SelectObject (hdcTempImage, hBrush); 1009 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY); 1010 DeleteObject (hBrush); 1011 1012 SelectObject (hdcTempImage, 1013 bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25); 1014 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, 0x0A0329); 1015 1016 SelectObject (hdcImageList, himlLocal->hbmMask); 1017 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 1018 himlLocal->cy, hdcImageList, 1019 pimldp->i * himlLocal->cx, 0, SRCPAINT); 1020 1021 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1022 hdcTempImage, 0, 0, SRCPAINT); 1023 1024 DeleteObject (hbmTempImage); 1025 DeleteDC (hdcTempImage); 1026 } 1027 } 1028 1029 /* Draw overlay image */ 1030 if (pimldp->fStyle & 0x0700) { 1031 nOvlIdx = (pimldp->fStyle & 0x0700) >> 8; 1032 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) { 1033 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 1034 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) { 1035 if (pimldp->himl->hbmMask) { 1036 SelectObject (hdcImageList, pimldp->himl->hbmMask); 1037 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1038 hdcImageList, pimldp->himl->cx * nOvlIdx, 0, 1039 SRCAND); 1040 } 1041 SelectObject (hdcImageList, pimldp->himl->hbmImage); 1042 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, 1043 cx, cy, hdcImageList, 1044 pimldp->himl->cx * nOvlIdx, 0, SRCPAINT); 1045 } 1046 } 1047 } 1048 1049 DeleteDC (hdcImageList); 1273 IMAGELIST_InternalDrawOverlay(pimldp, cx, cy); 1274 } 1050 1275 1051 1276 return TRUE; … … 1211 1436 ICONINFO ii; 1212 1437 HICON hIcon; 1438 HBITMAP hOldSrcBitmap,hOldDstBitmap; 1213 1439 HDC hdcSrc, hdcDst; 1214 1440 1215 1441 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) 1216 1442 return 0; 1217 1443 1218 1444 hdcSrc = CreateCompatibleDC(0); … … 1221 1447 ii.fIcon = TRUE; 1222 1448 ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1223 ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);1224 1225 1449 1226 1450 /* draw mask*/ 1227 SelectObject (hdcDst, ii.hbmMask);1451 hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); 1228 1452 if (himl->hbmMask) { 1229 1230 1231 1453 SelectObject (hdcSrc, himl->hbmMask); 1454 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1455 hdcSrc, i * himl->cx, 0, SRCCOPY); 1232 1456 } 1233 1457 else 1234 1458 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1235 1459 1236 1460 /* draw image*/ 1461 hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage); 1462 ii.hbmColor = CreateCompatibleBitmap (hdcSrc, himl->cx, himl->cy); 1237 1463 SelectObject (hdcDst, ii.hbmColor); 1238 SelectObject (hdcSrc, himl->hbmImage);1239 1464 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1240 hdcSrc, i * himl->cx, 0, SRCCOPY); 1465 hdcSrc, i * himl->cx, 0, SRCCOPY); 1466 1467 /* 1468 * CreateIconIndirect requires us to deselect the bitmaps from 1469 * the DCs before calling 1470 */ 1471 SelectObject(hdcSrc, hOldSrcBitmap); 1472 SelectObject(hdcDst, hOldDstBitmap); 1241 1473 1242 1474 hIcon = CreateIconIndirect (&ii);
Note:
See TracChangeset
for help on using the changeset viewer.