zoukankan      html  css  js  c++  java
  • Transparent 之 TransparentBlt

    • TransparentBlt函数
      BOOL TransparentBlt(
        HDC hdcDest,        // handle to destination DC
        int nXOriginDest,   // x-coord of destination upper-left corner
        int nYOriginDest,   // y-coord of destination upper-left corner
        int nWidthDest,     // width of destination rectangle
        int hHeightDest,    // height of destination rectangle
        HDC hdcSrc,         // handle to source DC
        int nXOriginSrc,    // x-coord of source upper-left corner
        int nYOriginSrc,    // y-coord of source upper-left corner
        int nWidthSrc,      // width of source rectangle
        int nHeightSrc,     // height of source rectangle
        UINT crTransparent  // color to make transparent
      
    • 示例
      static HBITMAP hBmp;
      static int cxBmp;
      static int cyBmp;
      
           case WM_CREATE:
      		{
      			//load bmp and get bmp info
      			hBmp = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BALL));
      			BITMAP bmpInfo;
      			GetObject(hBmp,sizeof(BITMAP),&bmpInfo);
      			cxBmp = bmpInfo.bmWidth;
      			cyBmp = bmpInfo.bmHeight;
      			//put window int the middle screen
      			int cxScr = GetSystemMetrics(SM_CXSCREEN);
      			int cyScr = GetSystemMetrics(SM_CYSCREEN);
      			int cxWnd = 400;
      			int cyWnd = 400;
      			MoveWindow(hWnd,(cxScr-cxWnd)/2,(cyScr-cyWnd)/2,cxWnd,cyWnd,TRUE);
      		}
      		break;
      
      	case WM_PAINT:
      		hdc = BeginPaint(hWnd, &ps);
      		{
      			//bg color
      			RECT rcWnd;
      			HBRUSH hBrush;
      			GetClientRect(hWnd,&rcWnd);
      			hBrush = CreateSolidBrush(RGB(0,128,128));
      			FillRect(hdc,&rcWnd,hBrush);
      			DeleteObject(hBrush);
      			//disp bmp
      			HDC hMemDC = CreateCompatibleDC(hdc);
      			HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDC,hBmp);
      			//BitBlt(hdc,73,58,cxBmp,cyBmp,hMemDC,0,0,SRCCOPY);
      			TransparentBlt(hdc,73,58,cxBmp,cyBmp,hMemDC,0,0,cxBmp,cyBmp,RGB(255,255,255));
      			SelectObject(hMemDC,hOldBmp);
      			DeleteDC(hMemDC);
      
      		}
      		EndPaint(hWnd, &ps);
      		break;
      
    • 结果
    • BitBlt:
    • TransparentBlt:
  • 相关阅读:
    Java操作Redis的方式
    Redis综述
    KafKa综述
    NuxtJS项目——状态树
    NuxtJS项目——开发工具
    NuxtJS项目——命令和部署
    NuxtJS项目——模块
    NuxtJS项目——插件
    NuxtJS项目——资源文件
    Sampling Matrix
  • 原文地址:https://www.cnblogs.com/dahai/p/2101645.html
Copyright © 2011-2022 走看看