如何画透明位图

{ //必须是全局的,这样使位图的混合过程alpha设置相同 static BLENDFUNCTION bf; CPaintDC ldc(this); CDC MemDC; CBitmap Bitmap1, Bitmap2; MemDC.CreateCompatibleDC( &ldc ); Bitmap1.LoadBitmap(IDB_BITMAP1); //纯红 Bitmap2.LoadBitmap(IDB_BITMAP2); //纯黑 BITMAP bmp1, bmp2; Bitmap1.GetBitmap( &bmp1 ); Bitmap2.GetBitmap( &bmp2); MemDC.SelectObject( &Bitmap2 ); ldc.BitBlt(0,0,bmp2.bmWidth, bmp2.bmHeight, &MemDC, 0,0, SRCCOPY); MemDC.SelectObject( &Bitmap1 ); bf.BlendOp = AC_SRC_OVER; //必须 bf.BlendFlags = 0; // 必须 bf.AlphaFormat = 0; bf.SourceConstantAlpha = 150; //不透明度 // 直接与窗口混合 ldc.AlphaBlend(0,0,bmp1.bmWidth,bmp1.bmHeight, &MemDC,0,0,bmp1.bmWidth,bmp1.bmHeight, bf ); }

你可能感兴趣的:(如何画透明位图)