MCPcopy Create free account
hub / github.com/cinience/RedisStudio / DrawImage

Method DrawImage

DuiLib/Core/UIRender.cpp:450–897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450void CRenderEngine::DrawImage(HDC hDC, HBITMAP hBitmap, const RECT& rc, const RECT& rcPaint,
451 const RECT& rcBmpPart, const RECT& rcCorners, bool alphaChannel,
452 BYTE uFade, bool hole, bool xtiled, bool ytiled)
453{
454 ASSERT(::GetObjectType(hDC)==OBJ_DC || ::GetObjectType(hDC)==OBJ_MEMDC);
455
456 typedef BOOL (WINAPI *LPALPHABLEND)(HDC, int, int, int, int,HDC, int, int, int, int, BLENDFUNCTION);
457 static LPALPHABLEND lpAlphaBlend = (LPALPHABLEND) ::GetProcAddress(::GetModuleHandle(_T("msimg32.dll")), "AlphaBlend");
458
459 if( lpAlphaBlend == NULL ) lpAlphaBlend = AlphaBitBlt;
460 if( hBitmap == NULL ) return;
461
462 HDC hCloneDC = ::CreateCompatibleDC(hDC);
463 HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hCloneDC, hBitmap);
464 ::SetStretchBltMode(hDC, HALFTONE);
465
466 RECT rcTemp = {0};
467 RECT rcDest = {0};
468 if( lpAlphaBlend && (alphaChannel || uFade < 255) ) {
469 BLENDFUNCTION bf = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA };
470 // middle
471 if( !hole ) {
472 rcDest.left = rc.left + rcCorners.left;
473 rcDest.top = rc.top + rcCorners.top;
474 rcDest.right = rc.right - rc.left - rcCorners.left - rcCorners.right;
475 rcDest.bottom = rc.bottom - rc.top - rcCorners.top - rcCorners.bottom;
476 rcDest.right += rcDest.left;
477 rcDest.bottom += rcDest.top;
478 if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
479 if( !xtiled && !ytiled ) {
480 rcDest.right -= rcDest.left;
481 rcDest.bottom -= rcDest.top;
482 lpAlphaBlend(hDC, rcDest.left, rcDest.top, rcDest.right, rcDest.bottom, hCloneDC, \
483 rcBmpPart.left + rcCorners.left, rcBmpPart.top + rcCorners.top, \
484 rcBmpPart.right - rcBmpPart.left - rcCorners.left - rcCorners.right, \
485 rcBmpPart.bottom - rcBmpPart.top - rcCorners.top - rcCorners.bottom, bf);
486 }
487 else if( xtiled && ytiled ) {
488 LONG lWidth = rcBmpPart.right - rcBmpPart.left - rcCorners.left - rcCorners.right;
489 LONG lHeight = rcBmpPart.bottom - rcBmpPart.top - rcCorners.top - rcCorners.bottom;
490 int iTimesX = (rcDest.right - rcDest.left + lWidth - 1) / lWidth;
491 int iTimesY = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight;
492 for( int j = 0; j < iTimesY; ++j ) {
493 LONG lDestTop = rcDest.top + lHeight * j;
494 LONG lDestBottom = rcDest.top + lHeight * (j + 1);
495 LONG lDrawHeight = lHeight;
496 if( lDestBottom > rcDest.bottom ) {
497 lDrawHeight -= lDestBottom - rcDest.bottom;
498 lDestBottom = rcDest.bottom;
499 }
500 for( int i = 0; i < iTimesX; ++i ) {
501 LONG lDestLeft = rcDest.left + lWidth * i;
502 LONG lDestRight = rcDest.left + lWidth * (i + 1);
503 LONG lDrawWidth = lWidth;
504 if( lDestRight > rcDest.right ) {
505 lDrawWidth -= lDestRight - rcDest.right;
506 lDestRight = rcDest.right;
507 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected