Page 1 of 1

How to get a hDC from a PureBasic image?

Posted: Sun Sep 29, 2019 12:00 am
by Mistrel
Given a PureBasic image created by CreateImage(), how can I get a hDC (device context handle) for drawing with Win32 functions?

I used to be able to do this in older versions of PureBasic:

Code: Select all

hDC=StartDrawing(ImageOutput(Image))
Unsurprisingly, this undocumented feature no longer works.

Re: How to get a hDC from a PureBasic image?

Posted: Sun Sep 29, 2019 1:56 am
by chi
Still working with PB 5.71 LTS

Code: Select all

CreateImage(0, 320, 200, 24, #Blue)
SetRect_(fill.RECT, 25, 50, 100, 150)

hdc = StartDrawing(ImageOutput(0))
  FillRect_(hdc, fill, GetStockObject_(#GRAY_BRUSH))
StopDrawing()

ShowLibraryViewer("Image", 0)
CallDebugger

Re: How to get a hDC from a PureBasic image?

Posted: Tue Oct 01, 2019 1:38 pm
by BarryG
Mistrel wrote:Unsurprisingly, this undocumented feature no longer works.
Sure it does. Post a little snippet showing the failure, please.

Re: How to get a hDC from a PureBasic image?

Posted: Tue Oct 01, 2019 10:13 pm
by Mistrel
I should have included some sample code. I don't know in what instance this was failing. :|

This is my mistake.