void GuideControl::OnPaint()
{
    CStatic::OnPaint();

    CDC* dc = GetDC();
    if (!dc)
        return;

    BITMAP markInfo;
    uploadDone_.GetBitmap(&markInfo);

    CRect rect;
    GetClientRect(&rect);

    CDC markDc;
    markDc.CreateCompatibleDC(dc);

    CGdiObject* o = markDc.SelectObject(&uploadDone_);

    dc->MaskBlt(0, 0, markInfo.bmWidth, markInfo.bmHeight, &markDc, 0, 0,
                uploadDoneMask_, 0, 0, MAKEROP4(SRCPAINT, SRCCOPY));

    markDc.SelectObject(&uploadFailed_);
    dc->MaskBlt(170, 0, markInfo.bmWidth, markInfo.bmHeight, &markDc, 0, 0,
                uploadFailedMask_, 0, 0, MAKEROP4(SRCPAINT, SRCCOPY));

    markDc.SelectObject(o);

    ReleaseDC(dc);
}
Beispiel #2
0
void Test_MaskBlt_1bpp()
{
    HDC hdcDst, hdcSrc;
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        ULONG aulColors[2];
    } bmiData = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 1, BI_RGB, 0, 10, 10, 2,0}, {0, 0xFFFFFF}};
    PBITMAPINFO pbmi = (PBITMAPINFO)&bmiData;
    HBITMAP hbmDst, hbmSrc, hbmMsk;
    PUCHAR pjBitsDst, pjBitsSrc, pjBitsMsk;
    BOOL ret;

    /* Create a dest dc and bitmap */
    hdcDst = CreateCompatibleDC(NULL);
    hbmDst = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsDst, NULL, 0);
    SelectObject(hdcDst, hbmDst);

    /* Create a source dc and bitmap */
    hdcSrc = CreateCompatibleDC(NULL);
    hbmSrc = CreateDIBSection(hdcSrc, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsSrc, NULL, 0);
    SelectObject(hdcSrc, hbmSrc);

    /* Create a 1 bpp mask bitmap */
    hbmMsk = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0);

    /* Do the masking (SRCCOPY / NOOP) */
    pjBitsDst[0] = 0xAA;
    pjBitsSrc[0] = 0xCC;
    pjBitsMsk[0] = 0xF0;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pjBitsDst[0] == 0xCA, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    pjBitsDst[0] = 0x00;
    pjBitsSrc[0] = 0xFF;
    pjBitsMsk[0] = 0xF0;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pjBitsDst[0] == 0xF0, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Do the masking (NOTSRCERASE / SRCINVERT) */
    pjBitsDst[0] = 0xF0;
    pjBitsSrc[0] = 0xCC;
    pjBitsMsk[0] = 0xAA;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(NOTSRCERASE, SRCINVERT)); // 22
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pjBitsDst[0] == 0x16, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Do the masking (MERGEPAINT / DSxn) */
    pjBitsDst[0] = 0xF0;
    pjBitsSrc[0] = 0xCC;
    pjBitsMsk[0] = 0xAA;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(MERGEPAINT, 0x990000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pjBitsDst[0] == 0xE3, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

}
Beispiel #3
0
void Test_MaskBlt_Brush()
{
    HDC hdcDst, hdcSrc;
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        ULONG aulColors[2];
    } bmiData = {{sizeof(BITMAPINFOHEADER), 16, 16, 1, 1, BI_RGB, 0, 10, 10, 2,0}, {0, 0xFFFFFF}};
    PBITMAPINFO pbmi = (PBITMAPINFO)&bmiData;
    HBITMAP hbmDst, hbmSrc, hbmMsk;
    PULONG pulBitsDst, pulBitsSrc, pulBitsMsk;
    BOOL ret;
    HBRUSH hbr;

    /* Create a dest dc and bitmap */
    hdcDst = CreateCompatibleDC(NULL);
    hbmDst = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsDst, NULL, 0);
    SelectObject(hdcDst, hbmDst);

    /* Create a source dc and bitmap */
    hdcSrc = CreateCompatibleDC(NULL);
    hbmSrc = CreateDIBSection(hdcSrc, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsSrc, NULL, 0);
    SelectObject(hdcSrc, hbmSrc);

    hbr = CreateHatchBrush(HS_CROSS, 0);
    ok(hbr != 0, "failed to create brush\n");
    ok(SelectObject(hdcDst, hbr) != 0, "failed to select brush\n");

    /* Do the masking (SRCCOPY / NOOP) */
    pulBitsDst[0] = 0x00000000;
    pulBitsSrc[0] = 0xFFFFFFFF;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, NULL, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pulBitsDst[0] == 0, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]);

    /* Create a 1 bpp pattern brush */
    pbmi->bmiHeader.biWidth = 8;
    hbmMsk = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsMsk, NULL, 0);
    ok(hbmMsk != 0, "CreateDIBSection failed\n");
    hbr = CreatePatternBrush(hbmMsk);
    ok(hbr != 0, "CreatePatternBrush failed\n");
    ok(SelectObject(hdcDst, hbr) != 0, "failed to select brush\n");

    /* Do the masking (SRCCOPY / NOOP) */
    pulBitsDst[0] = 0x00000000;
    pulBitsSrc[0] = 0xFFFFFFFF;
    pulBitsMsk[0] = 0xCCAAFF00;
    ret = MaskBlt(hdcDst, 0, 0, 16, 1, hdcSrc, 0, 0, NULL, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pulBitsDst[0] == 0, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]);

}
void iupwinDrawBitmap(HDC hDC, HBITMAP hBitmap, HBITMAP hMask, int x, int y, int width, int height, int bpp)
{
  HDC hMemDC = CreateCompatibleDC(hDC);
  HBITMAP oldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);

  if (bpp == 32 && winAlphaBlend)
  {
    BLENDFUNCTION blendfunc;
    blendfunc.BlendOp = AC_SRC_OVER;
    blendfunc.BlendFlags = 0;
    blendfunc.SourceConstantAlpha = 0xFF;
    blendfunc.AlphaFormat = AC_SRC_ALPHA;

    winAlphaBlend(hDC, x, y, width, height, 
                  hMemDC, 0, 0, width, height, 
                  blendfunc);
  }
  else if (bpp == 8 && hMask)
    MaskBlt(hDC, x, y, width, height, 
            hMemDC, 0, 0, 
            hMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
  else
    BitBlt(hDC, x, y, width, height, 
           hMemDC, 0, 0, 
           SRCCOPY);

  SelectObject(hMemDC, oldBitmap);
  DeleteDC(hMemDC);
}
Beispiel #5
0
//Performs the cloning
void CloneTool::clone(DibSection * ds, SHIFT shift)
{
	HDC dib_cdc=ds->GetCompDC();
	//PLSPEC: NT only
	MaskBlt(dib_cdc,maskOffset.x,maskOffset.y,usedSize.cx,usedSize.cy,
		dib_cdc,maskOffset.x+shift.x,maskOffset.y+shift.y,
		mask->GetDSHandle(),0,0,
		MAKEROP4(ROP3_NOP,SRCCOPY));
}
Beispiel #6
0
void Test_MaskBlt_16bpp()
{
    HDC hdcDst, hdcSrc;
    BITMAPINFO bmi1 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 1, BI_RGB, 0, 10, 10, 0,0}};
    BITMAPINFO bmi32 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
    HBITMAP hbmDst, hbmSrc, hbmMsk;
    PUCHAR pjBitsMsk;
    PUSHORT pusBitsDst, pusBitsSrc;
    BOOL ret;

    /* Create a dest dc and bitmap */
    hdcDst = CreateCompatibleDC(NULL);
    hbmDst = CreateDIBSection(hdcDst, &bmi32, DIB_RGB_COLORS, (PVOID*)&pusBitsDst, NULL, 0);
    SelectObject(hdcDst, hbmDst);

    /* Create a source dc and bitmap */
    hdcSrc = CreateCompatibleDC(NULL);
    hbmSrc = CreateDIBSection(hdcSrc, &bmi32, DIB_RGB_COLORS, (PVOID*)&pusBitsSrc, NULL, 0);
    SelectObject(hdcSrc, hbmSrc);
    ok(hdcSrc && hbmSrc, "\n");

    /* Create a 1 bpp mask bitmap */
    hbmMsk = CreateDIBSection(hdcDst, &bmi1, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0);
    ok(hbmMsk != 0, "CreateDIBSection failed\n");

    /* Do the masking */
    pusBitsDst[0] = 0x1234;
    pusBitsDst[1] = 0x5678;
    pusBitsSrc[0] = 0x4321;
    pusBitsSrc[1] = 0x8765;
    pjBitsMsk[0] = 0x80;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pusBitsDst[0] == 0x4321, "pusBitsDst[0] == 0x%x\n", pusBitsDst[0]);
    ok (pusBitsDst[1] == 0x5678, "pusBitsDst[0] == 0x%x\n", pusBitsDst[1]);

    pusBitsDst[0] = 0x1234;
    pusBitsDst[1] = 0x5678;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCPAINT, MERGEPAINT));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok (pusBitsDst[0] == 0x5335, "pusBitsDst[0] == 0x%x\n", pusBitsDst[0]);
    ok (pusBitsDst[1] == 0x7efa, "pusBitsDst[0] == 0x%x\n", pusBitsDst[1]);
}
Beispiel #7
0
void CGDALContainer::DrawImage(HDC hDC, double dWorldOriginX, double dWorldOriginY, uint index) {
	
	if (hDC == NULL) return;
	int		length	= geoTiffs.size();
	HDC		hDCMem	= CreateCompatibleDC(hDC);
	HBITMAP hMemBitmap;
	HBITMAP hbMask;
	HGDIOBJ oldObject = NULL;


	// have we got a device context?
	if (hDCMem) {
		// are we in range?
		if (index >= 0 && index < geoTiffs.size()) {
			
			// draw only if layer is uptodate
			if (geoTiffs[index]->isUptodate) {

				int currentBufferSize = geoTiffs[index]->getBufferSize();
				
				// create new DIBSection for drawing the layer in
				hMemBitmap = ::CreateDIBSection(hDCMem, geoTiffs[index]->getBitmapInfo(), DIB_RGB_COLORS, (void **)&buffer, NULL, 0);
				if (hMemBitmap) {
					
					// copy the layer data into the DIBSection
					// memcpy_s(void *dest, size_t numberOfElements, const void *src, size_t count);
					memcpy_s(this->buffer, currentBufferSize, geoTiffs[index]->getBytes(), currentBufferSize);
					
					// select the DIBSection into temp dc
					oldObject = SelectObject(hDCMem, hMemBitmap);

					// get the mask of the layer
					geoTiffs[index]->getMask(hbMask);

					// blt the drawn layer through the mask onto our real device context
					MaskBlt(hDC, geoTiffs[index]->getRelativeX(), geoTiffs[index]->getRelativeY(), width, height,
						hDCMem, 0, 0, hbMask, 0, 0,
						MAKEROP4(geoTiffs[index]->getRasterOperation(), 0x00AA0029)); // 0x00AA0029 == Destination
					
					// Select old object back into dc (one can not delete an object if it is in the dc)
					SelectObject(hDCMem, oldObject);

					// delete the now unselected object
					DeleteObject(hMemBitmap);
				}
			}
		}
		DeleteDC(hDCMem);
	}
}
Beispiel #8
0
BOOL wbDrawBitmap(HANDLE handle, HBITMAP hbmBits, int xPos, int yPos, int nWidth, int nHeight, int xOffset, int yOffset, COLORREF clTransp)
{
	BOOL bRet;
	HDC hdcMem;
	HBITMAP hbmMask = NULL;

	if(!hbmBits)
		return FALSE;

	if(!DrawStart(handle))
		return FALSE;

	if(nWidth < 1 && nHeight < 1) {
		DWORD dwDim;

		dwDim = wbGetImageDimensions(hbmBits);
		nWidth = LOWORD(dwDim);
		nHeight = HIWORD(dwDim);
	}

	if(clTransp != CLR_INVALID)
		hbmMask = wbCreateMask(hbmBits, clTransp);

	hdcMem = CreateCompatibleDC(hdcMain);
	SelectObject(hdcMem, hbmBits);

	if(clTransp != CLR_INVALID) {

		bRet = MaskBlt(hdcMain,
			xPos, yPos, nWidth, nHeight,
			hdcMem,
			xOffset, yOffset,
			hbmMask,
			xOffset, yOffset,
			MAKEROP4(SRCPAINT, SRCCOPY));

	} else {
		bRet = BitBlt(hdcMain, xPos, yPos, nWidth, nHeight, hdcMem, xOffset, yOffset, SRCCOPY);
	}
	DeleteDC(hdcMem);

	if((clTransp != CLR_INVALID) && hbmMask)
		DeleteObject(hbmMask);

	if(!DrawEnd(handle))
		return FALSE;

	return bRet;
}
void ToppyFramework::Draw(CDC* pDC)
{
	CDC* pMemDC = GetDC();


	if (NeedsRepaint())
	{
		m_TheState.Draw(pMemDC);

		CDC osdDC;
		osdDC.CreateCompatibleDC(pDC);
		osdDC.SetBkColor(TRANSPARENT_COLOUR);
		CBitmap bmOsd;
		bmOsd.CreateCompatibleBitmap(pDC, 720, 576);
		osdDC.SelectObject(&bmOsd);
		osdDC.FillSolidRect(0,0,720,576,TRANSPARENT_COLOUR);
		if (m_OSDregions.Draw(&osdDC))
		{
			CDC monoDC;
			monoDC.CreateCompatibleDC(pDC);
			CBitmap maskBm;
			maskBm.CreateBitmap(720, 576, 1, 1, NULL);
			monoDC.SelectObject(maskBm);
			osdDC.SetBkColor(TRANSPARENT_COLOUR);
			monoDC.BitBlt(0, 0, 720, 576, &osdDC, 0, 0, SRCCOPY);

			CDC tempDC;
			tempDC.CreateCompatibleDC(pDC);
			CBitmap tempBM;
			tempBM.CreateCompatibleBitmap(pDC, 720, 576);
			tempDC.SelectObject(&tempBM);
			tempDC.BitBlt(0,0, 720, 576, pMemDC, 0, 0, SRCCOPY);

			BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255-(BYTE)(GetConfig()->GetOsdTransparency() * 255/100), 0};
			pMemDC->AlphaBlend(0, 0, 720, 576, &osdDC, 0, 0, 720, 576, bf );
	//
	////		 now contains correct over OSD area, wrong in background
	//
			pMemDC->MaskBlt(0,0, 720, 576, &tempDC, 0, 0, maskBm, 0, 0, MAKEROP4(SRCCOPY, DSTCOPY));
			//memDC.BitBlt(0, 0, 720, 576, &osdDC, 0, 0, SRCCOPY);
		}
	}

	pDC->BitBlt(0,0, 720, 576, pMemDC, 0, 0, SRCCOPY); 
	ReleaseDC();
}
Beispiel #10
0
void num_out(HDC dc, int x, int y, HBITMAP mask, int value, char *descr)
{
	char temp[32];
	int count, i, n;
	HDC hdccomp;

	hdccomp = CreateCompatibleDC(dc);
	SelectObject(hdccomp, mask);

	itoa(value, temp, 10);
	count = (int)strlen(temp);
	for(i = 0; i < count; ++i)
	{
		n = temp[i] - '0';
		MaskBlt(
			dc, x, y+2, MASK_W, MASK_H,
			hdccomp, 0, 0, mask, n * MASK_W, 0, 
			MAKEROP4(PATCOPY, 0x00AA0029));
		x += MASK_W;
	}
	TextOut(dc, x + 5, y, descr, (int)strlen(descr));

	DeleteDC(hdccomp);
}
Beispiel #11
0
LRESULT dlgWndBadPIN::ProcecEvent
			(	UINT		uMsg,			// Message For This Window
				WPARAM		wParam,			// Additional Message Information
				LPARAM		lParam )		// Additional Message Information
{
	PAINTSTRUCT ps;
	RECT rect;

	switch( uMsg )
	{
		case WM_COMMAND:
		{
			switch( LOWORD(wParam) )
			{

				case IDB_OK:
					dlgResult = eIDMW::DLG_OK;
					close();
					return TRUE;

				case IDB_CANCEL:
					dlgResult = eIDMW::DLG_CANCEL;
					close();
					return TRUE;

				case IDB_RETRY:
					dlgResult = eIDMW::DLG_RETRY;
					close();
					return TRUE;

				default:
					return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
			}
		}


		case WM_SIZE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_SIZE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return 0;
			break;
		}

		case WM_PAINT:
		{
			m_hDC = BeginPaint( m_hWnd, &ps );

				HDC hdcMem;

				hdcMem = CreateCompatibleDC( m_hDC );
				SelectObject( hdcMem , ImagePIN );

				MaskBlt( m_hDC, 4, 4, IMG_SIZE, IMG_SIZE,
					hdcMem, 0, 0,
					ImagePIN_Mask, 0, 0,
					MAKEROP4( SRCCOPY, 0x00AA0029 ) );

				DeleteDC(hdcMem);

				GetClientRect( m_hWnd, &rect );
				rect.left += 136;
				rect.top += 32;
				rect.right -= 8;
				rect.bottom = 136 - 8;
				SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
				SelectObject( m_hDC, TextFont );
				DrawText( m_hDC, szHeader, -1, &rect, DT_WORDBREAK );

			EndPaint( m_hWnd, &ps );

			SetForegroundWindow( m_hWnd );

			return 0;
		}

		case WM_NCACTIVATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_NCACTIVATE (wParam=%X, lParam=%X)",wParam,lParam);

			if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			{
				ShowWindow( m_hWnd, SW_SHOW );
				SetFocus( m_hWnd );
				return 0;
			}
			break;
		}

		case WM_KILLFOCUS:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_KILLFOCUS (wParam=%X, lParam=%X)",wParam,lParam);

			if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			{
				if( GetParent((HWND)wParam ) != m_hWnd )
				{
					SetFocus( m_hWnd );
					return 0;
				}
			}
			break;
		}

		case WM_CREATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_CREATE (wParam=%X, lParam=%X)",wParam,lParam);

			HMENU hSysMenu;

			hSysMenu = GetSystemMenu( m_hWnd, FALSE );
			EnableMenuItem( hSysMenu, 2, MF_BYPOSITION | MF_GRAYED );

			return 1;
		}


		case WM_CLOSE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_CLOSE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return DefWindowProc( m_hWnd, uMsg, wParam, lParam );

			ShowWindow( m_hWnd, SW_MINIMIZE );
			return 0;
		}

		case WM_DESTROY: 
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndBadPIN::ProcecEvent WM_DESTROY (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		default:
		{
			return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
		}
	}
	return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
}
Beispiel #12
0
void OnPaint(HWND hWnd, HDC hdc, PAINTSTRUCT *ps)

{

#ifdef USE_WATERMARK

    TODAYDRAWWATERMARKINFO dwi;

#endif



    HDC drawdc, tempdc;

    HBITMAP hDrawBitMap;

    HBITMAP hRetDrawBmp;

//	HBITMAP hRetBmp;

    RECT rect;

    RECT selrect;

//	BITMAP bmp;

    int x, y;

    int i;

    HBRUSH hBrush;



    GetClientRect(hWnd, (LPRECT)&rect);



    drawdc = CreateCompatibleDC(hdc);

    tempdc = CreateCompatibleDC(hdc);

    hDrawBitMap = CreateCompatibleBitmap(hdc, rect.right, rect.bottom);

    hRetDrawBmp = SelectObject(drawdc, hDrawBitMap);



#ifdef USE_WATERMARK



    dwi.hdc = drawdc;

    GetClientRect(hWnd, &dwi.rc);

    dwi.hwnd = hWnd;

    SendMessage(GetParent(hWnd), TODAYM_DRAWWATERMARK, 0, (LPARAM)&dwi);



#else

    FillRect(drawdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));

#endif





    x = WinLeftMargin;

    y = WinTopMargin;



    for(i = 0; i < FileListCnt; i++) {



        if(SelItem == i) {

            SetRect(&selrect, x, y, x + IconSizeX + (HMargin * 2),

                    y + IconSizeY + (VMargin * 2));

            hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));

            FillRect(drawdc, &selrect, hBrush);

            DeleteObject(hBrush);

        }



        SelectObject(tempdc, FileList[i].bitmap);





#ifdef USE_MASKS

        MaskBlt(drawdc,

                x+HMargin, y+VMargin,

                IconSizeX, IconSizeY,

                tempdc, 0, 0, FileList[i].mask, 0, 0,

                MAKEROP4(0x00AA0029,SRCCOPY));

#else

        TransparentBlt(drawdc,

                       x+HMargin, y+VMargin,

                       IconSizeX, IconSizeY,

                       tempdc, 0, 0, IconSizeX, IconSizeY, RGB(0, 0, 255));

#endif



        x+= IconSizeX+HMargin*2;



    }



    BitBlt(hdc, ps->rcPaint.left, ps->rcPaint.top, ps->rcPaint.right, ps->rcPaint.bottom,

           drawdc, ps->rcPaint.left, ps->rcPaint.top, SRCCOPY);





    SelectObject(drawdc, hRetDrawBmp);

    DeleteObject(hDrawBitMap);

    DeleteDC(drawdc);

    DeleteDC(tempdc);

}
Beispiel #13
0
void Test_PatBlt_Params()
{
    BOOL ret;
    ULONG i, rop;
    HDC hdc;

    /* Test a rop that contains only the operation index */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
    ok_long(ret, 1);

    /* Test a rop that contains arbitrary values outside the operation index */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
    ok_long(ret, 1);

    /* Test an invalid rop  */
    SetLastError(0);
    ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
    ok_err(0);

    /* Test all rops */
    for (i = 0; i < 256; i++)
    {
        rop = i << 16;
        ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop);

        /* Only these should succeed (they use no source) */
        if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) ||
            (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) ||
            (i == 170) || (i == 175) || (i == 240) || (i == 245) ||
            (i == 250) || (i == 255))
        {
            ok(ret == 1, "index %ld failed, but should succeed\n", i);
        }
        else
        {
            ok(ret == 0, "index %ld succeeded, but should fail\n", i);
        }
    }

    /* Test quaternary rop, the background part is simply ignored */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT));
    ok_long(ret, 1);
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY));
    ok_long(ret, 1);
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY));
    ok_long(ret, 0);

    /* Test an info DC */
    hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
    ok(hdc != 0, "\n");
    SetLastError(0);
    ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
    ok_err(0);
    DeleteDC(hdc);

    /* Test a mem DC without selecting a bitmap */
    hdc = CreateCompatibleDC(NULL);
    ok(hdc != 0, "\n");
    ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
    ok_err(0);
    DeleteDC(hdc);



}
Beispiel #14
0
KHMEXP void KHMAPI
khui_ilist_draw(khui_ilist * il,
                int idx,
                HDC dc,
                int x,
                int y,
                int opt) {
    HDC dci;
    HBITMAP hb_oldi;

    if(idx < 0)
        return;

    dci = CreateCompatibleDC(dc);

    hb_oldi = SelectObject(dci, il->img);

    /*BitBlt(dc, x, y, il->cx, il->cy, dci, idx*il->cx, 0, SRCCOPY); */
    MaskBlt(dc, x, y, il->cx, il->cy, dci, idx * il->cx, 0, il->mask, idx * il->cx, 0, MAKEROP4(SRCPAINT, SRCCOPY));
/*    MaskBlt(dc, x, y, il->cx, il->cy, dci, idx * il->cx, 0, il->mask, idx * il->cx, 0, MAKEROP4(SRCINVERT, SRCCOPY)); */

    SelectObject(dci, hb_oldi);

    DeleteDC(dci);
}
Beispiel #15
0
void
endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_FREESEL:
        {
            POINT *ptStackCopy;
            int i;
            rectSel_src[0] = rectSel_src[1] = 0x7fffffff;
            rectSel_src[2] = rectSel_src[3] = 0;
            for (i = 0; i <= ptSP; i++)
            {
                if (ptStack[i].x < rectSel_src[0])
                    rectSel_src[0] = ptStack[i].x;
                if (ptStack[i].y < rectSel_src[1])
                    rectSel_src[1] = ptStack[i].y;
                if (ptStack[i].x > rectSel_src[2])
                    rectSel_src[2] = ptStack[i].x;
                if (ptStack[i].y > rectSel_src[3])
                    rectSel_src[3] = ptStack[i].y;
            }
            rectSel_src[2] += 1 - rectSel_src[0];
            rectSel_src[3] += 1 - rectSel_src[1];
            rectSel_dest[0] = rectSel_src[0];
            rectSel_dest[1] = rectSel_src[1];
            rectSel_dest[2] = rectSel_src[2];
            rectSel_dest[3] = rectSel_src[3];
            if (ptSP != 0)
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                ptStackCopy = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * (ptSP + 1));
                for (i = 0; i <= ptSP; i++)
                {
                    ptStackCopy[i].x = ptStack[i].x - rectSel_src[0];
                    ptStackCopy[i].y = ptStack[i].y - rectSel_src[1];
                }
                Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE);
                HeapFree(GetProcessHeap(), 0, ptStackCopy);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                MaskBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                        rectSel_src[1], hSelMask, 0, 0, MAKEROP4(SRCCOPY, WHITENESS));
                Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE);
                newReversible();

                MaskBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                        0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            HeapFree(GetProcessHeap(), 0, ptStack);
            ptStack = NULL;
            break;
        }
        case TOOL_RECTSEL:
            resetToU1();
            if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0))
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                Rect(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], 0x00ffffff, 0x00ffffff, 1, 2);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                       rectSel_src[1], SRCCOPY);
                Rect(hdc, rectSel_src[0], rectSel_src[1], rectSel_src[0] + rectSel_src[2],
                     rectSel_src[1] + rectSel_src[3], bgColor, bgColor, 0, TRUE);
                newReversible();

                BitBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                       0, SRCCOPY);

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            break;
        case TOOL_RUBBER:
            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, fg, 1);
            SetPixel(hdc, x, y, fg);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
            break;
        case TOOL_BEZIER:
            pointSP++;
            if (pointSP == 4)
                pointSP = 0;
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            pointSP++;
            if (pointSP >= 2)
            {
                if ((pointStack[0].x - x) * (pointStack[0].x - x) +
                    (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1)
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE);
                    pointSP = 0;
                }
                else
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE);
                }
            }
            if (pointSP == 255)
                pointSP--;
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
    }
}
Beispiel #16
0
// TODO code: optimise airspace drawing (same as DrawAirSpace())
// draw airspace using alpha blending
//static 
void MapWindow::DrawTptAirSpace(HDC hdc, const RECT rc) {
  // since standard GDI functions (brushes, pens...) ignore alpha octet in ARGB 
  // color value and don't set it in the resulting bitmap, we cannot use
  // perpixel alpha blending, instead we use global opacity for alpha blend 
  // (same opacity for all pixels); for fully "transparent" areas (without 
  // airspace) we must copy destination bitmap into source bitmap first so that 
  // alpha blending of such areas results in the same pixels as origin pixels 
  // in destination 
  CAirspaceList::const_iterator it;
  CAirspaceList::const_reverse_iterator itr;
  const CAirspaceList& airspaces_to_draw = CAirspaceManager::Instance().GetNearAirspacesRef();
  int airspace_type;
  bool found = false;
  bool borders_only = (GetAirSpaceFillType() == asp_fill_ablend_borders);
  bool outlined_only=(GetAirSpaceFillType()==asp_fill_border_only);

  static bool asp_selected_flash = false;
  asp_selected_flash = !asp_selected_flash;
   
  int nDC1 = SaveDC(mhdcbuffer);
  int nDC2 = SaveDC(hDCMask);
  int nDC3 = SaveDC(hDCTemp);
  
  // Draw airspace area
    if (1) {
    CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef());
    if (borders_only) {
       // Draw in reverse order!
       // The idea behind this, is lower top level airspaces are smaller. (statistically)
       // They have to be draw later, because inside border area have to be in correct color,
       // not the color of the bigger airspace above this small one.
      for (itr=airspaces_to_draw.rbegin(); itr != airspaces_to_draw.rend(); ++itr) {
            if ((*itr)->DrawStyle() == adsFilled) {
              airspace_type = (*itr)->Type();
              if (!found) {
                found = true;
                ClearTptAirSpace(hdc, rc);
              }
              // set filling brush
              SelectObject(mhdcbuffer, GetAirSpaceSldBrushByClass(airspace_type));
              (*itr)->Draw(mhdcbuffer, rc, true);
              (*itr)->Draw(hDCMask, rc, false);
            }
      }//for
    } else {
       // Draw in direct order!
      for (it=airspaces_to_draw.begin(); it != airspaces_to_draw.end(); ++it) {
            if ((*it)->DrawStyle() == adsFilled) {
              airspace_type = (*it)->Type();
              if (!found) {
                found = true;
                ClearTptAirSpace(hdc, rc);
              }
              // set filling brush
              SelectObject(hDCTemp, GetAirSpaceSldBrushByClass(airspace_type));
              (*it)->Draw(hDCTemp, rc, true);
            }
      }//for
    }//else borders_only
    }//mutex release

  // alpha blending
  if (found) {
    if (borders_only) {
        MaskBlt(hDCTemp,
                rc.left,rc.top,
                rc.right-rc.left,rc.bottom-rc.top,
                mhdcbuffer,rc.left,rc.top,
                hMaskBitMap,rc.left,rc.top, MAKEROP4(SRCAND,  0x00AA0029));
    }
    DoAlphaBlend(hdc, rc, hDCTemp, rc, (255 * GetAirSpaceOpacity()) / 100);
  }
  
  // draw it again, just the outlines
  
  // we will be drawing directly into given hdc, so store original PEN object
  HPEN hOrigPen = (HPEN) SelectObject(hdc, GetStockObject(WHITE_PEN));

    if (1) {
    CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef());
	for (it=airspaces_to_draw.begin(); it != airspaces_to_draw.end(); ++it) {
        if ((*it)->DrawStyle()) {
		  airspace_type = (*it)->Type();
		  if ( (((*it)->DrawStyle()==adsFilled)&&!outlined_only&&!borders_only)  ^ (asp_selected_flash && (*it)->Selected()) ) {
			SelectObject(hdc, GetStockObject(BLACK_PEN));
		  } else {
			SelectObject(hdc, hAirspacePens[airspace_type]);
		  }
		  (*it)->Draw(hdc, rc, false);
        }
	}//for
    }
  
  // restore original PEN
  SelectObject(hdc, hOrigPen);
  
  RestoreDC(mhdcbuffer, nDC1);
  RestoreDC(hDCMask, nDC2);    
  RestoreDC(hDCTemp, nDC3);    
} // DrawTptAirSpace()
JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_GDIBlitter_xorImage
  (JNIEnv *env, jobject obj, jint srcX, jint srcY, jlong srcSurfStruct, jobject srcData, 
  jint dstX, jint dstY, jlong dstSurfStruct, jint width, jint height, jint xorcolor, 
  jdoubleArray matrix, jintArray clip, jint numVertex, jboolean invalidated, 
  jintArray dirtyRegions, jint regCount){

      SURFACE_STRUCTURE *srcSurf = (SURFACE_STRUCTURE *)srcSurfStruct;
      SURFACE_STRUCTURE *dstSurf = (SURFACE_STRUCTURE *)dstSurfStruct;

      srcSurf->invalidated = invalidated != 0;

      int *regions;
      if(dirtyRegions == 0){
          regCount = 4;
          regions = (int *)malloc(4 * sizeof(int));
          regions[0] = 0;
          regions[1] = 0;
          regions[2] = srcSurf->width - 1;
          regions[3] = srcSurf->height - 1;
      } else {
          regions = (int *)malloc(regCount * sizeof(int));
          env->GetIntArrayRegion(dirtyRegions, 1, regCount, regions);
      }
      if(!initBitmap(srcSurf, env, srcData, false, regions, regCount)) return;

      BYTE r = (BYTE)((xorcolor >> 16) & 0xff);
      BYTE g = (BYTE)((xorcolor >> 8) & 0xff);
      BYTE b = (BYTE)(xorcolor & 0xff);

      HBRUSH brush = CreateSolidBrush(RGB(r, g, b));


      XFORM currentTransform, transform;
      if(matrix != NULL){

          jdouble * mtrx = (jdouble *)env->GetPrimitiveArrayCritical(matrix, 0);
          jdouble * old_mtrx = mtrx;

          transform.eM11 = (FLOAT)(*mtrx++);
          transform.eM12 = (FLOAT)(*mtrx++);
          transform.eM21 = (FLOAT)(*mtrx++);
          transform.eM22 = (FLOAT)(*mtrx++);
          transform.eDx = (FLOAT)(*mtrx++);
          transform.eDy = (FLOAT)(*mtrx);

          env->ReleasePrimitiveArrayCritical(matrix, old_mtrx, 0);

          SetGraphicsMode(dstSurf->gi->hdc, GM_ADVANCED);
          GetWorldTransform(dstSurf->gi->hdc, &currentTransform);
          SetWorldTransform(dstSurf->gi->hdc, &transform);
      }

      HRGN oldClip = setGdiClip(env, dstSurf->gi->hdc, clip, numVertex);

      HGDIOBJ oldBrush = SelectObject(dstSurf->gi->hdc, brush);

      if(srcSurf->has_alpha){

          int scanline_word = srcSurf->width / 16;
          if(srcSurf->width % 16 != 0) scanline_word++;

          BYTE *pm = (BYTE *)calloc(scanline_word * srcSurf->height * 2, 1);

          int byteIdx = 0;
          unsigned int *p = (unsigned int *)srcSurf->bmpData;
          for(int y = 0; y < srcSurf->height; y++){
              for(int x = 0, shift = 7; x < srcSurf->width; x++, shift--, p++){
                  if(shift < 0 ){
                      shift = 7;
                      byteIdx++;
                  } 
                  unsigned int pixel = (*p >> 24) & 0xff;
                  if(pixel > 127) pm[byteIdx] |= 1 << shift;
              }
              if(byteIdx % 2 != 0) byteIdx++;
              else byteIdx += 2;
          }      

          HBITMAP mask = CreateBitmap(srcSurf->width, srcSurf->height, 1, 1, pm);
          free(pm);
          MaskBlt(dstSurf->gi->hdc, dstX, dstY, width, height, srcSurf->srcDC,
                  srcX, srcY, mask, srcX, srcY, MAKEROP4(0x960169, 0xAA0029));
          DeleteObject(mask);
      }else{
Beispiel #18
0
HICON IconFactory::getIcon()
{
	HDC hdc = ::GetDC(NULL);

	HDC hdcMask = ::CreateCompatibleDC(hdc);
	HBITMAP hbmMask = ::CreateCompatibleBitmap(hdc, ICON_W, ICON_H);
	HBITMAP oldMask = SelectBitmap(hdcMask, hbmMask);

	HDC hdcColor = ::CreateCompatibleDC(hdc);
	HBITMAP hbmColor = ::CreateCompatibleBitmap(hdc, ICON_W, ICON_H);
	HBITMAP oldColor = SelectBitmap(hdcColor, hbmColor);

	HDC hdcChar = ::CreateCompatibleDC(hdc);
	HBITMAP hbmChar = ::CreateCompatibleBitmap(hdc, CHAR_W, CHAR_H);
	HBITMAP oldChar = SelectBitmap(hdcChar, hbmChar);

	HDC hdcWeekdays = ::CreateCompatibleDC(hdc);
	HBITMAP oldWeekdays = SelectBitmap(hdcWeekdays, this->hbmWeekdays);

	HDC hdcAscii = ::CreateCompatibleDC(hdc);
	HBITMAP oldAscii = SelectBitmap(hdcAscii, this->hbmAscii);

	// init mask as transparent
	::FillRect(hdcMask, &rcIcon, GetStockBrush(WHITE_BRUSH));
	::FillRect(hdcColor, &rcIcon, GetStockBrush(BLACK_BRUSH));


	// generate date buffer
	char buff[CHAR_N] = {0};
	this->set2dtoa(this->sysTime.wMonth, buff);
	this->set2dtoa(this->sysTime.wDay, buff + 2);
	::FillRect(hdcChar, &rcChar, this->dateBrush);
	for (char i = 0; i < CHAR_N; i++) {
		int x = GAP_LEFT + (CHAR_W + CHAR_GAP) * i;
		int y = LINETOP_0;
		int yMask = CHAR_H * (buff[i] - ' ');
		::BitBlt(hdcMask, x, y, CHAR_W, CHAR_H, hdcAscii, 0, yMask, SRCCOPY);
		::MaskBlt(hdcColor, x, y, CHAR_W, CHAR_H, hdcChar, 0, 0, this->hbmAscii, 0, yMask, MAKEROP4(BLACKNESS, SRCCOPY));
	}

	// generate time buffer
	this->set2dtoa(this->sysTime.wHour, buff);
	this->set2dtoa(this->sysTime.wMinute, buff + 2);
	::FillRect(hdcChar, &rcChar, this->timeBrush);
	for (char i = 0; i < CHAR_N; i++) {
		int x = GAP_LEFT + (CHAR_W + CHAR_GAP) * i;
		int y = LINETOP_1;
		int yMask = CHAR_H * (buff[i] - ' ');
		::BitBlt(hdcMask, x, y, CHAR_W, CHAR_H, hdcAscii, 0, yMask, SRCCOPY);
		::MaskBlt(hdcColor, x, y, CHAR_W, CHAR_H, hdcChar, 0, 0, this->hbmAscii, 0, yMask, MAKEROP4(BLACKNESS, SRCCOPY));
	}

	// draw weekdays
	int yOffset = this->sysTime.wDayOfWeek * WEEKDAY_H;
	::BitBlt(hdcColor, GAP_LEFT, WEEKTOP, WEEKDAY_W, WEEKDAY_H, hdcWeekdays, 0, yOffset, SRCCOPY);
	::BitBlt(hdcMask, GAP_LEFT, WEEKTOP, WEEKDAY_W, WEEKDAY_H, hdcWeekdays, 0, yOffset, BLACKNESS);

	// present seconds
	static unsigned char secPArray[WEEKDAY_W * WEEKDAY_H] = {0};
	if (this->secType & 0x80 || secPArray[0] == secPArray[1] || this->sysTime.wSecond == 0) {
		this->generatePArray(secPArray, sizeof(secPArray));
	}

	for (char i = 0; i < this->sysTime.wSecond; i++) {
		int x = GAP_LEFT + (secPArray[i] & 0x0f);
		int y = (secPArray[i] >> 4) + WEEKTOP;
		::SetPixel(hdcMask, x, y, RGB(0xff, 0xff, 0xff));
		::SetPixel(hdcColor, x, y, RGB(0, 0, 0));
	}


	SelectBitmap(hdcChar, oldChar);
	SelectBitmap(hdcColor, oldColor);
	SelectBitmap(hdcMask, oldMask);
	SelectBitmap(hdcWeekdays, oldWeekdays);
	SelectBitmap(hdcAscii, oldAscii);

	// generate icon
	ICONINFO ii = {0};
	ii.fIcon = TRUE;
	ii.hbmMask = hbmMask;
	ii.hbmColor = hbmColor;
	
	HICON hIcon = ::CreateIconIndirect(&ii);

	DeleteBitmap(hbmColor);
	DeleteBitmap(hbmMask);
	DeleteBitmap(hbmChar);

	::DeleteDC(hdcChar);
	::DeleteDC(hdcColor);
	::DeleteDC(hdcMask);
	::DeleteDC(hdcWeekdays);
	::DeleteDC(hdcAscii);
	::ReleaseDC(NULL, hdc);

	return hIcon;
}
Beispiel #19
0
BOOL
SecMgrDisplayXGraphic(
    IN  HWND                hwnd,
    IN  INT                 ControlId,
    IN  BOOL                Stronger
    )
{
    HWND
        ControlHandle;

    LONG
        ControlStyle;


    //
    // Make sure the control into which we are about to set this graphic
    // is a bitmap.
    //

    SecMgrpSetControlToBitmap( hwnd, ControlId );

    //
    // Now put the bitmap in the control
    //
//efine EXPERIMENT
#ifndef EXPERIMENT

    if (Stronger) {
        SendDlgItemMessage( hwnd, ControlId, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)SecMgrpUpArrowBitMap );
    }  else {
        SendDlgItemMessage( hwnd, ControlId, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)SecMgrpXBitMap );
    }
#else

    {
        BOOL
            Result;

        HWND
            ControlHandle;

        HDC
            ControlDC,
            CompatibleDC;

        BITMAP
            BitmapInfo;

        RECT
            ControlRect;

        //
        //
        
        ControlHandle = GetDlgItem( hwnd, ControlId);
DbgPrint(" ControlHandle = %d (0x%lx)\n", ControlHandle, ControlHandle );
        ControlDC = GetDC( ControlHandle );
DbgPrint(" ControlDC     = %d (0x%lx)\n", ControlDC, ControlDC );
        CompatibleDC = CreateCompatibleDC( ControlDC );
DbgPrint(" CompatibleDC  = %d (0x%lx)\n", CompatibleDC, CompatibleDC );

        if (CompatibleDC != NULL) {

            if (GetWindowRect( ControlHandle, &ControlRect )) {
DbgPrint(" WindowRec (Left,top) (%d,%d)\n", ControlRect.left, ControlRect.top );

                SelectObject( CompatibleDC, SecMgrpXBitMap );
                GetObject (SecMgrpXBitMap, sizeof(BITMAP), &BitmapInfo);
                Result =  MaskBlt (ControlDC,
                                   ControlRect.left,
                                   ControlRect.top, 
                                   BitmapInfo.bmWidth,
                                   BitmapInfo.bmHeight,
                                   CompatibleDC,
                                   0, 0,
                                   SecMgrpXBitMapMask, 
                                   0,0,
                                   MAKEROP4(SRCCOPY,SRCAND));
#if DBG
if (Result) {
DbgPrint(" MaskBlt worked\n");
} else {
DbgPrint(" MaskBlt ** FAILED ** GetLastError() = %d (0x%lx)\n", GetLastError(), GetLastError());
}
#endif  //DBG

            }
            DeleteDC (CompatibleDC);
        }


    }

#endif   // EXPERIMENT

    return(TRUE);

}
Beispiel #20
0
// for each white pixel in the mask, do nothing (NOP), and for each black pixel, do a Copy.
bool LKSurface::CopyWithMask(int nXDest, int nYDest, int nWidth, int nHeight, const LKSurface& hdcSrc, int nXSrc, int nYSrc, const LKBitmapSurface& bmpMask, int xMask, int yMask) {
#ifdef USE_GDI
    return ::MaskBlt(*this, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, bmpMask, xMask, yMask, MAKEROP4(SRCAND,  0x00AA0029));
#else
    Canvas& buffer = hdcSrc;
    buffer.CopyNotOr(nXDest, nYDest, nWidth, nHeight, bmpMask, xMask, yMask);
    _pCanvas->Copy(nXDest, nYDest, nWidth, nHeight, buffer, nXSrc, nYSrc);
    return true;
#endif
}
void CGradientEditor::CStepHandle::OnDraw(HDC hDC, const LPRECT clientRect)
{
	int xSrc = dragging ? WIDTH : 0;
	UpdateBounds();
	MaskBlt(hDC, bounds.left, bounds.top, WIDTH, HEIGHT, parent->shBitmapDC, xSrc, 0, parent->shBmpMask, xSrc, 0, MAKEROP4(SRCCOPY, 0xAA0029));
	SetBrushOrgEx(hDC, -20, 0, NULL);
	SelectObject(hDC, GetStockObject(DC_BRUSH));
	SetDCBrushColor(hDC, gradient->GetStepColor(stepID));
	WorkingMaskBlt(hDC, bounds.left, bounds.top, WIDTH, HEIGHT, hDC, xSrc, 0, parent->shBmpColorMask, xSrc, 0, MAKEROP4(PATCOPY, 0xAA0029));
}
Beispiel #22
0
LRESULT CALLBACK
SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_PAINT:
        {
            if (!moving)
            {
                HDC hDC = GetDC(hwnd);
                DefWindowProc(hwnd, message, wParam, lParam);
                SelectionFrame(hDC, 1, 1, rectSel_dest[2] * zoom / 1000 + 5,
                               rectSel_dest[3] * zoom / 1000 + 5);
                ReleaseDC(hwnd, hDC);
            }
            break;
        }
        case WM_LBUTTONDOWN:
            xPos = LOWORD(lParam);
            yPos = HIWORD(lParam);
            SetCapture(hwnd);
            if (action != 0)
                SetCursor(LoadCursor(NULL, cursors[action]));
            moving = TRUE;
            break;
        case WM_MOUSEMOVE:
            if (moving)
            {
                TCHAR sizeStr[100];
                int xDelta;
                int yDelta;
                resetToU1();
                xFrac += (short)LOWORD(lParam) - xPos;
                yFrac += (short)HIWORD(lParam) - yPos;
                if (zoom < 1000)
                {
                    xDelta = xFrac * 1000 / zoom;
                    xFrac = 0;
                    yDelta = yFrac * 1000 / zoom;
                    yFrac = 0;
                }
                else
                {
                    xDelta = xFrac * 1000 / zoom;
                    xFrac -= (xFrac * 1000 / zoom) * zoom / 1000;
                    yDelta = yFrac * 1000 / zoom;
                    yFrac -= (yFrac * 1000 / zoom) * zoom / 1000;
                }
                switch (action)
                {
                    case 0:
                        rectSel_dest[0] += xDelta;
                        rectSel_dest[1] += yDelta;
                        break;
                    case 1:
                        rectSel_dest[0] += xDelta;
                        rectSel_dest[1] += yDelta;
                        rectSel_dest[2] -= xDelta;
                        rectSel_dest[3] -= yDelta;
                        break;
                    case 2:
                        rectSel_dest[1] += yDelta;
                        rectSel_dest[3] -= yDelta;
                        break;
                    case 3:
                        rectSel_dest[2] += xDelta;
                        rectSel_dest[1] += yDelta;
                        break;
                    case 4:
                        rectSel_dest[0] += xDelta;
                        rectSel_dest[2] -= xDelta;
                        break;
                    case 5:
                        rectSel_dest[2] += xDelta;
                        break;
                    case 6:
                        rectSel_dest[0] += xDelta;
                        rectSel_dest[2] -= xDelta;
                        rectSel_dest[3] += yDelta;
                        break;
                    case 7:
                        rectSel_dest[3] += yDelta;
                        break;
                    case 8:
                        rectSel_dest[2] += xDelta;
                        rectSel_dest[3] += yDelta;
                        break;
                }

                _stprintf(sizeStr, _T("%d x %d"), rectSel_dest[2], rectSel_dest[3]);
                SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);

                if (action != 0)
                    StretchBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
                else
                if (transpBg == 0)
                    MaskBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3],
                            hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
                else
                {
                    HBITMAP tempMask;
                    HBRUSH oldBrush;
                    HDC tempDC;
                    tempMask = CreateBitmap(rectSel_dest[2], rectSel_dest[3], 1, 1, NULL);
                    oldBrush = SelectObject(hSelDC, CreateSolidBrush(bgColor));
                    tempDC = CreateCompatibleDC(hSelDC);
                    SelectObject(tempDC, tempMask);
                    MaskBlt(tempDC, 0, 0, rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, hSelMask, 0, 0,
                            MAKEROP4(NOTSRCCOPY, BLACKNESS));
                    DeleteDC(tempDC);
                    DeleteObject(SelectObject(hSelDC, oldBrush));

                    MaskBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3],
                            hSelDC, 0, 0, tempMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
                    DeleteObject(tempMask);
                }
                SendMessage(hImageArea, WM_PAINT, 0, 0);
                xPos = LOWORD(lParam);
                yPos = HIWORD(lParam);
                //SendMessage(hwnd, WM_PAINT, 0, 0);
            }
            else
            {
                int w = rectSel_dest[2] * zoom / 1000 + 6;
                int h = rectSel_dest[3] * zoom / 1000 + 6;
                xPos = LOWORD(lParam);
                yPos = HIWORD(lParam);
                SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) NULL);
                action = identifyCorner(xPos, yPos, w, h);
                if (action != 0)
                    SetCursor(LoadCursor(NULL, cursors[action]));
            }
            break;
        case WM_LBUTTONUP:
            if (moving)
            {
                moving = FALSE;
                ReleaseCapture();
                if (action != 0)
                {
                    HDC hTempDC;
                    HBITMAP hTempBm;
                    hTempDC = CreateCompatibleDC(hSelDC);
                    hTempBm = CreateDIBWithProperties(rectSel_dest[2], rectSel_dest[3]);
                    SelectObject(hTempDC, hTempBm);
                    SelectObject(hSelDC, hSelBm);
                    StretchBlt(hTempDC, 0, 0, rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0,
                               GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
                    DeleteObject(hSelBm);
                    hSelBm = hTempBm;
                    hTempBm = CreateBitmap(rectSel_dest[2], rectSel_dest[3], 1, 1, NULL);
                    SelectObject(hTempDC, hTempBm);
                    SelectObject(hSelDC, hSelMask);
                    StretchBlt(hTempDC, 0, 0, rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0,
                               GetDIBWidth(hSelMask), GetDIBHeight(hSelMask), SRCCOPY);
                    DeleteObject(hSelMask);
                    hSelMask = hTempBm;
                    SelectObject(hSelDC, hSelBm);
                    DeleteDC(hTempDC);
                }
                placeSelWin();
                ShowWindow(hSelection, SW_HIDE);
                ShowWindow(hSelection, SW_SHOW);
            }
            break;
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Beispiel #23
0
LRESULT dlgWndAskPIN::ProcecEvent
			(	UINT		uMsg,			// Message For This Window
				WPARAM		wParam,			// Additional Message Information
				LPARAM		lParam )		// Additional Message Information
{
	PAINTSTRUCT ps;
	RECT rect;

	switch( uMsg )
	{ 
		case WM_COMMAND:
		{
			switch( LOWORD(wParam) )
			{
				case IDC_EDIT:
				{
					if( EN_CHANGE == HIWORD(wParam) )
					{
						long len = (long)SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_GETTEXTLENGTH, 0, 0 );
						EnableWindow( GetDlgItem( m_hWnd, IDOK ), ( (unsigned int)len >= m_ulPinMinLen ) );
					}
					return TRUE;
				}

				case IDB_OK:
					GetPinResult();
					dlgResult = eIDMW::DLG_OK;
					close();
					return TRUE;

				case IDB_CANCEL:
					dlgResult = eIDMW::DLG_CANCEL;
					close();
					return TRUE;

				default:
					unsigned short tmp = LOWORD(wParam);
					if( tmp >= IDB_KeypadStart && tmp < IDB_KeypadEnd ) // Keypad Buttons
					{
						wchar_t nameBuf[128];
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_GETTEXT, (WPARAM)(sizeof(nameBuf)), (LPARAM)nameBuf );
						size_t iPos = wcslen( nameBuf );
						if( iPos >= m_ulPinMaxLen )
							return TRUE;
						if( tmp == IDB_KeypadEnd - 1 ) // Keypad Button 0
						{
							nameBuf[ iPos++ ] = L'0';
						}
						else // Keypad Button 1 to 9
						{
							nameBuf[ iPos++ ] = 49 + tmp - IDB_KeypadStart;
						}
						nameBuf[ iPos++ ] = NULL;
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_SETTEXT, 0, (LPARAM)nameBuf );
						return TRUE;
					}
					if( tmp == IDB_KeypadEnd ) // Keypad Button CE
					{
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_SETTEXT, 0, (LPARAM)"" );
						//clear
					}
					return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
			}
		}

		case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
			if( lpDrawItem->CtlType & ODT_BUTTON )
			{
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM lParam=%x, wParam=%ld",lParam,wParam);
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - Entering WM_DRAWITEM lpDrawItem->hDC=%ld",lpDrawItem->hDC);

				FillRect( lpDrawItem->hDC, &lpDrawItem->rcItem, CreateSolidBrush( GetSysColor( COLOR_3DFACE ) ) );
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM top=%ld, bottom=%ld, left=%ld, right=%ld",
					//lpDrawItem->rcItem.top,lpDrawItem->rcItem.bottom,lpDrawItem->rcItem.left,lpDrawItem->rcItem.right);

				HDC hdcMem = CreateCompatibleDC( lpDrawItem->hDC );
				SelectObject( hdcMem , ImageKP_BTN[11] );
				MaskBlt( lpDrawItem->hDC, (lpDrawItem->rcItem.right - KP_BTN_SIZE) / 2, (lpDrawItem->rcItem.bottom - KP_BTN_SIZE) / 2,
					KP_BTN_SIZE, KP_BTN_SIZE, hdcMem, 0, 0,
					ImageKP_BTN_Mask, 0, 0, MAKEROP4( SRCCOPY, 0x00AA0029 ) );

				unsigned int iNum = 0;
				if( lpDrawItem->CtlID == IDB_KeypadEnd )
				{
					iNum = 10;
				}
				else if( lpDrawItem->CtlID >= IDB_KeypadStart && lpDrawItem->CtlID < IDB_KeypadEnd -2 )
				{
					iNum = lpDrawItem->CtlID - IDB_KeypadStart +1;
				}
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM iNum=%ld",iNum);

				SelectObject( hdcMem , ImageKP_BTN[iNum] );
				BitBlt( lpDrawItem->hDC, (lpDrawItem->rcItem.right - KP_LBL_SIZE) / 2, (lpDrawItem->rcItem.bottom - KP_LBL_SIZE) / 2, 
						KP_LBL_SIZE, KP_LBL_SIZE, hdcMem, 0, 0, SRCCOPY );
				DeleteDC(hdcMem);

				if( lpDrawItem->itemState & ODS_SELECTED )
					DrawEdge( lpDrawItem->hDC, &lpDrawItem->rcItem, EDGE_RAISED, BF_RECT );
				
				if( lpDrawItem->itemState & ODS_HOTLIGHT )
					DrawEdge( lpDrawItem->hDC, &lpDrawItem->rcItem, EDGE_SUNKEN, BF_RECT );
				
				if( lpDrawItem->itemState & ODS_FOCUS )
				{
					GetClientRect( lpDrawItem->hwndItem, &rect );
					rect.left += 2;
					rect.right -= 2;
					rect.top += 2;
					rect.bottom -= 2;
					DrawFocusRect( lpDrawItem->hDC, &rect );
				}
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - Leaving WM_DRAWITEM lpDrawItem->hDC=%ld",lpDrawItem->hDC);
				return TRUE;
			}
			break;
		}

		case WM_SIZE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_SIZE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return 0;
			break;
		}

		case WM_PAINT:
		{
			//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : WM_PAINT");
			m_hDC = BeginPaint( m_hWnd, &ps );

			HDC hdcMem;

			hdcMem = CreateCompatibleDC( m_hDC );

			HGDIOBJ oldObj = SelectObject( hdcMem , ImagePIN );

			GetClientRect( m_hWnd, &rect );
			MaskBlt( m_hDC, 4, m_KeypadHeight + 8,
				IMG_SIZE, IMG_SIZE,	hdcMem, 0, 0,
				ImagePIN_Mask, 0, 0, MAKEROP4( SRCCOPY, 0x00AA0029 ) );
		
			
			SelectObject( hdcMem, oldObj );
			DeleteDC(hdcMem);

			if( m_UseKeypad )
			{
				GetClientRect( m_hWnd, &rect );
				rect.left += 8;
				rect.right -= 8;
				rect.top += 8;
				rect.bottom = m_KeypadHeight;

				DrawEdge( m_hDC, &rect, EDGE_RAISED, BF_RECT );
			}

			GetClientRect( m_hWnd, &rect );
			rect.left += IMG_SIZE + 16;
			rect.top = m_KeypadHeight + 8;
			rect.right -= 8;
			rect.bottom = rect.bottom - 40;
			SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
			SelectObject( m_hDC, TextFont );
			DrawText( m_hDC, szHeader, -1, &rect, DT_WORDBREAK );

			EndPaint( m_hWnd, &ps );

			SetForegroundWindow( m_hWnd );

			return 0;
		}

		case WM_ACTIVATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_ACTIVATE (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		case WM_NCACTIVATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_NCACTIVATE (wParam=%X, lParam=%X)",wParam,lParam);

			//if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			//{
			//	ShowWindow( m_hWnd, SW_SHOW );
			//	SetFocus( m_hWnd );
			//	return 0;
			//}
			if(!wParam)
			{
				SetFocus( m_hWnd );
				return 0;
			}
			break;
		}

		case WM_SETFOCUS:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_SETFOCUS (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		case WM_KILLFOCUS:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_KILLFOCUS (wParam=%X, lParam=%X)",wParam,lParam);

			//if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			//{
			//	if( GetParent((HWND)wParam ) != m_hWnd )
			//	{
			//		SetFocus( m_hWnd );
			//		return 0;
			//	}
			//}
			break;
		}

		case WM_CREATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_CREATE (wParam=%X, lParam=%X)",wParam,lParam);

			HMENU hSysMenu;

			hSysMenu = GetSystemMenu( m_hWnd, FALSE );
			EnableMenuItem( hSysMenu, 3, MF_BYPOSITION | MF_GRAYED );
			SendMessage( m_hWnd, DM_SETDEFID, (WPARAM) IDC_EDIT, (LPARAM) 0); 

			return DefWindowProc( (HWND)((CREATESTRUCT *)lParam)->lpCreateParams, uMsg, wParam, lParam );
		}

		case WM_CLOSE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_CLOSE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return DefWindowProc( m_hWnd, uMsg, wParam, lParam );

			ShowWindow( m_hWnd, SW_MINIMIZE );
			return 0;
		}

		case WM_DESTROY: 
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_DESTROY (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		default:
		{
			return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
		}
	}
	return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
}
Beispiel #24
0
/*****************************************************************************
 * SIC_OverlayShortcutImage            [internal]
 *
 * NOTES
 *  Creates a new icon as a copy of the passed-in icon, overlayed with a
 *  shortcut image.
 * FIXME: This should go to the ImageList implementation!
 */
static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large)
{    
    ICONINFO ShortcutIconInfo, TargetIconInfo;
    HICON ShortcutIcon = NULL, TargetIcon;
    BITMAP TargetBitmapInfo, ShortcutBitmapInfo;
    HDC ShortcutDC = NULL,
      TargetDC = NULL;
    HBITMAP OldShortcutBitmap = NULL,
      OldTargetBitmap = NULL;

    static int s_imgListIdx = -1;
    ZeroMemory(&ShortcutIconInfo, sizeof(ShortcutIconInfo));
    ZeroMemory(&TargetIconInfo, sizeof(TargetIconInfo));

    /* Get information about the source icon and shortcut overlay.
     * We will write over the source bitmaps to get the final ones */
    if (! GetIconInfo(SourceIcon, &TargetIconInfo))
        return NULL;
    
    /* Is it possible with the ImageList implementation? */
    if(!TargetIconInfo.hbmColor)
    {
        /* Maybe we'll support this at some point */
        FIXME("1bpp icon wants its overlay!\n");
        goto fail;
    }
        
    if(!GetObjectW(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo))
    {
        goto fail;
    }

    /* search for the shortcut icon only once */
    if (s_imgListIdx == -1)
        s_imgListIdx = SIC_LoadOverlayIcon(- IDI_SHELL_SHORTCUT);
                           /* FIXME should use icon index 29 instead of the
                              resource id, but not all icons are present yet
                              so we can't use icon indices */

    if (s_imgListIdx != -1)
    {
        if (large)
            ShortcutIcon = ImageList_GetIcon(ShellBigIconList, s_imgListIdx, ILD_TRANSPARENT);
        else
            ShortcutIcon = ImageList_GetIcon(ShellSmallIconList, s_imgListIdx, ILD_TRANSPARENT);
    } else
        ShortcutIcon = NULL;

    if (!ShortcutIcon || !GetIconInfo(ShortcutIcon, &ShortcutIconInfo))
    {
        goto fail;
    }
    
    /* Is it possible with the ImageLists ? */
    if(!ShortcutIconInfo.hbmColor)
    {
        /* Maybe we'll support this at some point */
        FIXME("Should draw 1bpp overlay!\n");
        goto fail;
    }
    
    if(!GetObjectW(ShortcutIconInfo.hbmColor, sizeof(BITMAP), &ShortcutBitmapInfo))
    {
        goto fail;
    }

    /* Setup the masks */
    ShortcutDC = CreateCompatibleDC(NULL);
    if (NULL == ShortcutDC) goto fail;
    OldShortcutBitmap = (HBITMAP)SelectObject(ShortcutDC, ShortcutIconInfo.hbmMask);
    if (NULL == OldShortcutBitmap) goto fail;

    TargetDC = CreateCompatibleDC(NULL);
    if (NULL == TargetDC) goto fail;
    OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmMask);
    if (NULL == OldTargetBitmap) goto fail;

    /* Create the complete mask by ANDing the source and shortcut masks.
     * NOTE: in an ImageList, all icons have the same dimensions */
    if (!BitBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
                ShortcutDC, 0, 0, SRCAND))
    {
      goto fail;
    }

    /*
     * We must remove or add the alpha component to the shortcut overlay:
     * If we don't, SRCCOPY will copy it to our resulting icon, resulting in a
     * partially transparent icons where it shouldn't be, and to an invisible icon
     * if the underlying icon don't have any alpha channel information. (16bpp only icon for instance).
     * But if the underlying icon has alpha channel information, then we must mark the overlay information
     * as opaque.
     * NOTE: This code sucks(tm) and should belong to the ImageList implementation.
     * NOTE2: there are better ways to do this.
     */
    if(ShortcutBitmapInfo.bmBitsPixel == 32)
    {
        BOOL add_alpha;
        BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
        BITMAPINFO* lpbmi = (BITMAPINFO*)buffer;
        PVOID bits;
        PULONG pixel;
        INT i, j;
        
        /* Find if the source bitmap has an alpha channel */
        if(TargetBitmapInfo.bmBitsPixel != 32) add_alpha = FALSE;
        else
        {
            ZeroMemory(buffer, sizeof(buffer));
            lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
            lpbmi->bmiHeader.biWidth = TargetBitmapInfo.bmWidth;
            lpbmi->bmiHeader.biHeight = TargetBitmapInfo.bmHeight;
            lpbmi->bmiHeader.biPlanes = 1;
            lpbmi->bmiHeader.biBitCount = 32;
            
            bits = HeapAlloc(GetProcessHeap(), 0, TargetBitmapInfo.bmHeight * TargetBitmapInfo.bmWidthBytes);
            
            if(!bits) goto fail;
            
            if(!GetDIBits(TargetDC, TargetIconInfo.hbmColor, 0, TargetBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
            {
                ERR("GetBIBits failed!\n");
                HeapFree(GetProcessHeap(), 0, bits);
                goto fail;
            }
            
            i = j = 0;
            pixel = (PULONG)bits;
            
            for(i=0; i<TargetBitmapInfo.bmHeight; i++)
            {
                for(j=0; j<TargetBitmapInfo.bmWidth; j++)
                {
                    add_alpha = (*pixel++ & 0xFF000000) != 0;
                    if(add_alpha) break;
                }
                if(add_alpha) break;
            }
            HeapFree(GetProcessHeap(), 0, bits);
        }
        
        /* Allocate the bits */
        bits = HeapAlloc(GetProcessHeap(), 0, ShortcutBitmapInfo.bmHeight*ShortcutBitmapInfo.bmWidthBytes);
        if(!bits) goto fail;
        
        ZeroMemory(buffer, sizeof(buffer));
        lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        lpbmi->bmiHeader.biWidth = ShortcutBitmapInfo.bmWidth;
        lpbmi->bmiHeader.biHeight = ShortcutBitmapInfo.bmHeight;
        lpbmi->bmiHeader.biPlanes = 1;
        lpbmi->bmiHeader.biBitCount = 32;
        
        if(!GetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
        {
            ERR("GetBIBits failed!\n");
            HeapFree(GetProcessHeap(), 0, bits);
            goto fail;
        }
        
        pixel = (PULONG)bits;
        /* Remove alpha channel component or make it totally opaque */
        for(i=0; i<ShortcutBitmapInfo.bmHeight; i++)
        {
            for(j=0; j<ShortcutBitmapInfo.bmWidth; j++)
            {
                if(add_alpha) *pixel++ |= 0xFF000000;
                else *pixel++ &= 0x00FFFFFF;
            }
        }
        
        /* GetDIBits return BI_BITFIELDS with masks set to 0, and SetDIBits fails when masks are 0. The irony... */
        lpbmi->bmiHeader.biCompression = BI_RGB;
        
        /* Set the bits again */
        if(!SetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
        {
            ERR("SetBIBits failed!, %lu\n", GetLastError());
            HeapFree(GetProcessHeap(), 0, bits);
            goto fail;
        }
        HeapFree(GetProcessHeap(), 0, bits);
    }

    /* Now do the copy. We overwrite the original icon data */
    if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor) ||
        NULL == SelectObject(TargetDC, TargetIconInfo.hbmColor))
        goto fail;
    if (!MaskBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
                 ShortcutDC, 0, 0, ShortcutIconInfo.hbmMask, 0, 0,
                 MAKEROP4(0xAA0000, SRCCOPY)))
    {
        goto fail;
    }

    /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set
       handles to NULL */
    SelectObject(TargetDC, OldTargetBitmap);
    DeleteDC(TargetDC);
    SelectObject(ShortcutDC, OldShortcutBitmap);
    DeleteDC(ShortcutDC);

    /* Create the icon using the bitmaps prepared earlier */
    TargetIcon = CreateIconIndirect(&TargetIconInfo);

    /* CreateIconIndirect copies the bitmaps, so we can release our bitmaps now */
    DeleteObject(TargetIconInfo.hbmColor);
    DeleteObject(TargetIconInfo.hbmMask);
    /* Delete what GetIconInfo gave us */
    DeleteObject(ShortcutIconInfo.hbmColor);
    DeleteObject(ShortcutIconInfo.hbmMask);
    DestroyIcon(ShortcutIcon);

    return TargetIcon;

fail:
    /* Clean up scratch resources we created */
    if (NULL != OldTargetBitmap) SelectObject(TargetDC, OldTargetBitmap);
    if (NULL != TargetDC) DeleteDC(TargetDC);
    if (NULL != OldShortcutBitmap) SelectObject(ShortcutDC, OldShortcutBitmap);
    if (NULL != ShortcutDC) DeleteDC(ShortcutDC);
    if (NULL != TargetIconInfo.hbmColor) DeleteObject(TargetIconInfo.hbmColor);
    if (NULL != TargetIconInfo.hbmMask) DeleteObject(TargetIconInfo.hbmMask);
    if (NULL != ShortcutIconInfo.hbmColor) DeleteObject(ShortcutIconInfo.hbmColor);
    if (NULL != ShortcutIconInfo.hbmMask) DeleteObject(ShortcutIconInfo.hbmMask);
    if (NULL != ShortcutIcon) DestroyIcon(ShortcutIcon);

    return NULL;
}
Beispiel #25
0
LRESULT dlgWndPinpadInfo::ProcecEvent(	UINT		uMsg,			// Message For This Window
									WPARAM		wParam,			// Additional Message Information
									LPARAM		lParam )		// Additional Message Information
{
	PAINTSTRUCT ps;
	RECT rect;

	switch( uMsg )
	{

	case WM_PAINT:
		{
			m_hDC = BeginPaint( m_hWnd, &ps );

			HDC hdcMem;

			hdcMem = CreateCompatibleDC( m_hDC );

			HGDIOBJ oldObj = SelectObject( hdcMem , ImagePIN );

			GetClientRect( m_hWnd, &rect );
			//Size of the background Image
			MaskBlt( m_hDC, 4, 8,
				410, 261,	hdcMem, 0, 0,
				ImagePIN_Mask, 0, 0, MAKEROP4( SRCCOPY, 0x00AA0029 ) );
		
			
			SelectObject( hdcMem, oldObj );
			DeleteDC(hdcMem);

			GetClientRect( m_hWnd, &rect );
			rect.left += IMG_SIZE + 100;
			rect.top = 32;
			rect.right -= 8;
			rect.bottom = 136 - 8;
			SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
			SelectObject( m_hDC, TextFont );
			DrawText( m_hDC, m_szHeader, -1, &rect, DT_WORDBREAK );

			//Change top header dimensions
			GetClientRect( m_hWnd, &rect );
			rect.left += IMG_SIZE + 100;
			rect.top = 60;
			rect.right -= 20;
			rect.bottom = rect.bottom - 60;
			SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
			SelectObject( m_hDC, TextFont );
			DrawText( m_hDC, m_szMessage, -1, &rect, DT_WORDBREAK );

			EndPaint( m_hWnd, &ps );

			SetForegroundWindow( m_hWnd );

			return 0;

/*
			m_hDC = BeginPaint( m_hWnd, &ps );

			HDC hdcMem;

			GetClientRect( m_hWnd, &rect );
			rect.bottom = rect.top + IMG_SIZE + 8;//rect.bottom / 2;
			FillRect( m_hDC, &rect, CreateSolidBrush( RGB(255, 255, 255) ) );

			hdcMem = CreateCompatibleDC( m_hDC );
			SelectObject( hdcMem , ImagePIN );
			BitBlt( m_hDC, 4, 4, IMG_SIZE, IMG_SIZE, hdcMem,
				0, 0, SRCCOPY );

			DeleteDC(hdcMem);

			rect.left += 136;
			rect.top += 32;
			rect.right -= 8;
			rect.bottom = 136 - 8;
			//SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
			DrawText( m_hDC, m_szHeader, -1, &rect, DT_WORDBREAK );

			GetClientRect( m_hWnd, &rect );
			rect.top=rect.top + IMG_SIZE + 8;

			rect.top = rect.top + 8;
			rect.bottom = rect.bottom - 8;
			rect.left = rect.left + 8;
			rect.right = rect.right - 8;
			FillRect( m_hDC, &rect, CreateSolidBrush( RGB(255, 255, 255) ) );

			rect.top = rect.top + 8;
			rect.bottom = rect.bottom - 8;
			rect.left = rect.left + 8;
			rect.right = rect.right - 8;
			DrawText( m_hDC, m_szMessage, -1, &rect, DT_WORDBREAK );

			EndPaint( m_hWnd, &ps );

			SetForegroundWindow( m_hWnd );

			return 0;
			*/
		}

		case WM_CREATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndPinpadInfo::ProcecEvent WM_CLOSE (wParam=%X, lParam=%X)",wParam,lParam);

			HMENU hSysMenu;

			hSysMenu = GetSystemMenu( m_hWnd, FALSE);
			EnableMenuItem( hSysMenu, 2, MF_BYPOSITION | MF_GRAYED );

			return 1;
		}

		case WM_CLOSE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndPinpadInfo::ProcecEvent WM_CLOSE (wParam=%X, lParam=%X)",wParam,lParam);

			if( m_ulHandle )
			{
				unsigned long tmp = m_ulHandle;
				m_ulHandle = 0;
				DlgClosePinpadInfo( tmp );
			}
			return  0;
		}

		case WM_DESTROY: 
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndModal::ProcecEvent WM_DESTROY (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		default:
		{
			return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
		}
	}
	return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
}
Beispiel #26
0
void Test_MaskBlt_1bpp()
{
    HDC hdcDst, hdcSrc;
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        ULONG aulColors[2];
    } bmiData = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 1, BI_RGB, 0, 10, 10, 2,0}, {0, 0xFFFFFF}};
    PBITMAPINFO pbmi = (PBITMAPINFO)&bmiData;
    HBITMAP hbmDst, hbmSrc, hbmMsk;
    PUCHAR pjBitsDst, pjBitsSrc, pjBitsMsk;
    BOOL ret;

    /* Create a dest dc and bitmap */
    hdcDst = CreateCompatibleDC(NULL);
    hbmDst = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsDst, NULL, 0);
    SelectObject(hdcDst, hbmDst);

    /* Create a source dc and bitmap */
    hdcSrc = CreateCompatibleDC(NULL);
    hbmSrc = CreateDIBSection(hdcSrc, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsSrc, NULL, 0);
    SelectObject(hdcSrc, hbmSrc);

    /* Create a 1 bpp mask bitmap */
    hbmMsk = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0);

    /* Do the masking (SRCCOPY / NOOP) */
    pjBitsDst[0] = 0xAA;
    pjBitsSrc[0] = 0xCC;
    pjBitsMsk[0] = 0xF0;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0xCA, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    pjBitsDst[0] = 0x00;
    pjBitsSrc[0] = 0xFF;
    pjBitsMsk[0] = 0xF0;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0xF0, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Do the masking (NOTSRCERASE / SRCINVERT) */
    pjBitsDst[0] = 0xF0; // 11110000
    pjBitsSrc[0] = 0xCC; // 11001100
    pjBitsMsk[0] = 0xAA; // 10101010

    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(NOTSRCERASE, SRCINVERT)); // 22
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0x16, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Do the masking (MERGEPAINT / DSxn) */
    pjBitsDst[0] = 0xF0;
    pjBitsSrc[0] = 0xCC;
    pjBitsMsk[0] = 0xAA;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(MERGEPAINT, 0x990000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0xE3, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Try a ROP that needs a mask with a NULL mask bitmap handle */
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, NULL, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0xCC, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

    /* Try a ROP that needs a mask with an invalid mask bitmap handle */
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, (HBITMAP)0x123456, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);

    /* Try a ROP that needs a mask with an invalid mask bitmap */
    ok(ghbmp24 != NULL, "ghbmp24 is NULL!\n");
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, ghbmp24, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);

    /* Try a ROP that needs no mask with an invalid mask bitmap */
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, (HBITMAP)0x123456, 0, 0, MAKEROP4(SRCCOPY, SRCCOPY));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);

    /* Try (PATCOPY / NOOP) with a NULL source mask and bitmap */
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, NULL, 0, 0, NULL, 0, 0, MAKEROP4(PATCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);


    /* Try with a mask that is smaller than the rect */
    DeleteObject(hbmMsk);
    pbmi->bmiHeader.biWidth = 4;
    hbmMsk = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0);

    /* Do the masking (SRCCOPY / NOOP) */
    pjBitsDst[0] = 0xAA; // 10101010
    pjBitsSrc[0] = 0xCC; // 11001100
    pjBitsMsk[0] = 0x33; // 00110011
    ret = MaskBlt(hdcDst, 0, 0, 5, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);
    ret = MaskBlt(hdcDst, 0, 0, 4, 1, hdcSrc, 0, 0, hbmMsk, 1, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);
    ret = MaskBlt(hdcDst, 0, 0, 4, 1, hdcSrc, 0, 0, hbmMsk, 0, 1, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 0, "MaskBlt should fail, but succeeded (%d)\n", ret);
    ret = MaskBlt(hdcDst, 0, 0, 4, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pjBitsDst[0] == 0x8A, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]);

}