How to get a hDC from a PureBasic image?

Windows specific forum
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

How to get a hDC from a PureBasic image?

Post 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.
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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
Et cetera is my worst enemy
BarryG
Addict
Addict
Posts: 3322
Joined: Thu Apr 18, 2019 8:17 am

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

Post by BarryG »

Mistrel wrote:Unsurprisingly, this undocumented feature no longer works.
Sure it does. Post a little snippet showing the failure, please.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

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

Post by Mistrel »

I should have included some sample code. I don't know in what instance this was failing. :|

This is my mistake.
Post Reply