How would I go about using BitBlt in python? I know how to use PatBlt, but I was wondering how you use BitBlt. How would I put a image on the GDI?
CodePudding user response:
If you already know how to use PatBlt then you are most of the way there.
BitBlt just transfers pixels from one DC to another. Often one DC has a bitmap selected into it and the other DC is the screen. It can be used to take screen shots, display pictures or do double buffering.
Let's say you have a bitmap loaded from LoadImage and you want to display it in WM_PAINT.
- Call
BeginPaintto get a DC for your window (the destination). - Call
CreateCompatibleDCto create a source DC that is compatible with the destination. - Call
SelectObjectto select the bitmap (HBITMAP) into the source DC. You should store the return value so it can be restored during cleanup. - Call
BitBlt(destination DC, ..., source DC, ...., SRCCOPY)to copy the bitmap pixels to the window. - Call
SelectObjectto restore the original value. - Call
DeleteDCto destroy the source DC. - Call
EndPaint.
