Page 2 of 2

Re: Using #PB_any give compiler error

Posted: Sun Jun 03, 2018 10:53 am
by Demivec
Michael Vogel wrote:

Code: Select all

FreeImage("temp")				;how to free the memory again?
Why wouldn't you use this?

Code: Select all

FreeImage(temp)

Re: Using #PB_any give compiler error

Posted: Sun Jun 03, 2018 11:05 am
by Michael Vogel
Demivec wrote:Why wouldn't you use this?

Code: Select all

FreeImage(temp)
Because FreeImage needs the image number (#Image) not the handle (*Image) as a parameter, isn't it?

Re: Using #PB_any give compiler error

Posted: Sun Jun 03, 2018 12:39 pm
by nco2k

Code: Select all

ImageID = CreateImage(0, 32, 32)
Debug ImageID
Debug ImageID(0)
FreeImage(0)

Debug ""

ImageAny = CreateImage(#PB_Any, 32, 32)
Debug ImageAny
Debug ImageID(ImageAny)
FreeImage(ImageAny)
#PB_Any does not return the image handle. it returns a pointer to the image object, inside a pb-internal image list. a static number (0-XXXX) is an index to the image object, inside a pb-internal image array.

c ya,
nco2k

Re: Using #PB_any give compiler error

Posted: Sun Jun 03, 2018 1:19 pm
by Michael Vogel
Thanks, so everything is correct and fine - just got really nervous because of the high values (expected, the next 'free' number would be chosen) :oops: ...

...but when comparing multiple pointers and numbers, the difference it obvisously:

Code: Select all

For i=1 To 10
	Debug CreateImage(i,1<<i,1<<i)
Next i

Debug ""

For i=1 To 10
	Debug CreateImage(#PB_Any,1<<i,1<<i)
Next i