CreateImage(PB_Any)

Just starting out? Need help? Post your questions and find answers here.
mestnyi
Addict
Addict
Posts: 1000
Joined: Mon Nov 25, 2013 6:41 am

CreateImage(PB_Any)

Post by mestnyi »

It looks like it returns a descriptor, not an id.
PB 562 x(64)

Code: Select all

imgs(i) = CreateImage(#PB_Any, Width, Height)
    
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: CreateImage(PB_Any)

Post by TI-994A »

mestnyi wrote:It looks like it returns a descriptor, not an id.
That's the ID. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
mestnyi
Addict
Addict
Posts: 1000
Joined: Mon Nov 25, 2013 6:41 am

Re: CreateImage(PB_Any)

Post by mestnyi »

TI-994A wrote:
mestnyi wrote:It looks like it returns a descriptor, not an id.
That's the ID. :wink:
What does this mean?
That's where I noticed it.
The following code gives an error.
On line 31 [ERROR] The specified #Image is Not initialised.
viewtopic.php?f=13&t=55683&hilit=pb_can ... ta#p419308
DarkDragon
Addict
Addict
Posts: 2228
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: CreateImage(PB_Any)

Post by DarkDragon »

TI-994A wrote:
mestnyi wrote:It looks like it returns a descriptor, not an id.
That's the ID. :wink:
Well there is the ImageID(Number), which is basically the native image identifier of the operating system, and there is the PB Image Identifier.

CreateXyz(Number, ...) often returns the XyzID(Number) and the Number is the PB Image Identifier.
CreateXyz(#PB_Any, ...) always returns the PB Xyz Identifier.

The reason for this is historical: in former times there was no support for dynamic object creation with PB_Any. You always had to manage the numbers yourself. Also if you pass numbers >= 0 instead of #PB_Any (which is -1 IIRC), PureBasic will store the objects in an array list and this array list will be large enough to store the highest number as elements in it. So CreateImage(10000, ...) will ensure that the array is 10000 elements big.
bye,
Daniel
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: CreateImage(PB_Any)

Post by TI-994A »

mestnyi wrote:The following code gives an error.
On line 31 [ERROR] The specified #Image is Not initialised.
viewtopic.php?f=13&t=55683&hilit=pb_can ... ta#p419308
That's not caused by the CreateImage() function or the #PB_Any directive. The error is caused by utilising a Long to hold the gadget numbers assigned by the 64bit compiler. Either compile the code with a 32bit compiler, or change the array to an Integer data type.

Essentially,

Code: Select all

Dim imgs.i(#NUMOFTILES)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply