Help with displaying an hBitmap on a canvas

Windows specific forum
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Help with displaying an hBitmap on a canvas

Post by ozzie »

Help, please, you Windows API gurus!

I'm using a video playback library that includes a callback event for each frame displayed, and I want to take that frame and display it in a second 'monitor' window which contains little more than a canvas gadget. The callback provides the frame as an hBitmap. How can I copy that image to my canvas gadget? Do I need to use something like BitBlt_?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Help with displaying an hBitmap on a canvas

Post by ts-soft »

Code: Select all

StartDrawing(CanvasOutput(#canvas))
  DrawImage(hBitmap, 0, 0)
StopDrawing()
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: Help with displaying an hBitmap on a canvas

Post by ozzie »

Many thanks - works perfectly (after adding the DrawImage Width and Height parameters to rescale the image). Didn't realize the solution would be so simple and standard-PB!
Post Reply