Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Alpha Blitting in GDI #110

Open
cnlohr opened this issue Oct 3, 2024 · 1 comment
Open

Switch to Alpha Blitting in GDI #110

cnlohr opened this issue Oct 3, 2024 · 1 comment

Comments

@cnlohr
Copy link
Member

cnlohr commented Oct 3, 2024

Just a feature that would be cool!

@cnlohr
Copy link
Member Author

cnlohr commented Oct 4, 2024

I got this far, and it doesn't actually blend... not sure why. Anyone else, any ideas?

}

void CNFGBlitImage( uint32_t * data, int x, int y, int w, int h )
{
	static int pbw, pbh;
	static HBITMAP pbb;
	if( !pbb || pbw != w || pbh !=h )
	{
		if( pbb ) DeleteObject( pbb );
		pbb = CreateBitmap( w, h, 1, 32, 0 );
		pbh = h;
		pbw = w;
	}
	
	int i;
	for( i = 0; i < w*h; i++ )
	{
		data[i] = rand() | 0x01000000; //(data[i] & 0xffffff ) | ((rand()&0xff)<<24);
	}
	
	SetBitmapBits(pbb,w*h*4,data);
	
	SelectObject( CNFGlsHDCBlit, pbb );
#ifdef GDI32NOUSEALPHA
	BitBlt(CNFGlsHDC, x, y, w, h, CNFGlsHDCBlit, 0, 0, SRCCOPY);
#else
	// If you use this, you will also need to link to -lmsimg32 
	static const BLENDFUNCTION BlendFunc = { .BlendOp = AC_SRC_OVER, .BlendFlags = 0, .SourceConstantAlpha = 255, .AlphaFormat = AC_SRC_ALPHA };	
	AlphaBlend( CNFGlsHDC, x, y, w, h, CNFGlsHDCBlit, 0, 0, w, h, BlendFunc );
#endif
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant