Posts: 89
Threads: 13
Joined: Apr 2022
Reputation:
9
I am working on a project in which I would like to create images using _NEWIMAGE and calculated image dimensions. I have found that an 'Illegal Function Call' error is raised when I try to create an image like this:
DIM AS LONG Pict
DIM AS INTEGER iy
.
.
.
Pict =_NEWIMAGE(64, iy, 32)
Does _NEWIMAGE accept only numeric values for the dimensions? The wiki doesn't specifically say so but all of the examples use numeric dimension values.
TIA
It's not the having, it's the doing.
Posts: 243
Threads: 15
Joined: Apr 2024
Reputation:
30
(02-17-2026, 12:59 AM)bobalooie Wrote: I am working on a project in which I would like to create images using _NEWIMAGE and calculated image dimensions. I have found that an 'Illegal Function Call' error is raised when I try to create an image like this:
DIM AS LONG Pict
DIM AS INTEGER iy
.
.
.
Pict =_NEWIMAGE(64, iy, 32)
Does _NEWIMAGE accept only numeric values for the dimensions? The wiki doesn't specifically say so but all of the examples use numeric dimension values.
TIA
A variable should be acceptable.
If that is the full code your using then your getting the illegal function call because iu isn't assigned a value (thus is 0) You can't do a _NEWIMAGE with a 0 dimension !
Posts: 89
Threads: 13
Joined: Apr 2022
Reputation:
9
(02-17-2026, 01:02 AM)ahenry3068 Wrote: A variable should be acceptable.
If that is the full code your using then your getting the illegal function call because iu isn't assigned a value (thus is 0) You can't do a _NEWIMAGE with a 0 dimension !
The variable's value is calculated before reaching this point in the code. It is a non-zero value.
It's not the having, it's the doing.
Posts: 243
Threads: 15
Joined: Apr 2024
Reputation:
30
02-17-2026, 01:11 AM
(This post was last modified: 02-17-2026, 01:13 AM by ahenry3068.)
(02-17-2026, 01:04 AM)bobalooie Wrote: (02-17-2026, 01:02 AM)ahenry3068 Wrote: A variable should be acceptable.
If that is the full code your using then your getting the illegal function call because iu isn't assigned a value (thus is 0) You can't do a _NEWIMAGE with a 0 dimension !
The variable's value is calculated before reaching this point in the code. It is a non-zero value. In that case please print out the values just prior to the _newimage. ! The code you have should work if iy is a valid value !
Also make sure the variable is **in scope** you may think your initializing it but really getting the WRONG iy if the one your assigning isn't in the scope of the _newimage
Posts: 89
Threads: 13
Joined: Apr 2022
Reputation:
9
(02-17-2026, 01:11 AM)ahenry3068 Wrote: (02-17-2026, 01:04 AM)bobalooie Wrote: (02-17-2026, 01:02 AM)ahenry3068 Wrote: A variable should be acceptable.
If that is the full code your using then your getting the illegal function call because iu isn't assigned a value (thus is 0) You can't do a _NEWIMAGE with a 0 dimension !
The variable's value is calculated before reaching this point in the code. It is a non-zero value. In that case please print out the values just prior to the _newimage. ! The code you have should work if iy is a valid value !
Also make sure the variable is **in scope** you may think your initializing it but really getting the WRONG iy if the one your assigning isn't in the scope of the _newimage
The action is all within a SUB, including the variable declarations, so everything is in the local scope. I have single-stepped through the code and put the variables on the watchlist. The iy values start at 16 and can be increased but never reduced.
It's not the having, it's the doing.
Posts: 243
Threads: 15
Joined: Apr 2024
Reputation:
30
(02-17-2026, 01:22 AM)bobalooie Wrote: (02-17-2026, 01:11 AM)ahenry3068 Wrote: (02-17-2026, 01:04 AM)bobalooie Wrote: The variable's value is calculated before reaching this point in the code. It is a non-zero value. In that case please print out the values just prior to the _newimage. ! The code you have should work if iy is a valid value !
Also make sure the variable is **in scope** you may think your initializing it but really getting the WRONG iy if the one your assigning isn't in the scope of the _newimage
The action is all within a SUB, including the variable declarations, so everything is in the local scope. I have single-stepped through the code and put the variables on the watchlist. The iy values start at 16 and can be increased but never reduced. I know I use variables with _NEWIMAGE, But I believe in double checking.
This code DOES NOTHING REALLY, But it compiles and runs without an error !
Code: (Select All)
Dim IX As Integer
Dim IY As Integer
Dim IMG As Long
IX = 64
IY = 16
IMG = _NewImage(IX, IY, 32)
Please Humor me and do a PRINT IY right before the NewImage !
(If you doing other things that would make that output hard to read then do a _DEST CONSOLE before the print ! )
Posts: 346
Threads: 45
Joined: Jun 2024
Reputation:
32
If your calling the creation from within a Sub and the variable iy isnt shared then the sub cant access it.
So i.e
DIM Shared AS INTEGER Iy
Would probably fix it
Though without your full code this is just a guess...
Unseen
Posts: 243
Threads: 15
Joined: Apr 2024
Reputation:
30
(02-17-2026, 01:51 AM)Unseen Machine Wrote: If your calling the creation from within a Sub and the variable iy isnt shared then the sub cant access it.
So i.e
DIM Shared AS INTEGER Iy
Would probably fix it
Though without your full code this is just a guess...
Unseen
I also suspect this, and did ask if the variable was in scope. He says everything is declared in the same sub ??
There has to be an incorrect value somewhere which is why I asked him to print out the value right before his call to _NewImage !
Posts: 4,695
Threads: 222
Joined: Apr 2022
Reputation:
322
02-17-2026, 02:02 AM
(This post was last modified: 02-17-2026, 02:11 AM by bplus.)
Works fine for me _NewImage with variables in a sub:
Code: (Select All)
Option _Explicit
Screen _NewImage(800, 600, 32): _ScreenMove 280, 60
Dim I
For I = 1 To 100
Line (Rnd * _Width, Rnd * _Height)-(Rnd * _Width, Rnd * _Height), _RGB32(Rnd * 255), BF
Next
Sleep
testNewImage
Sub testNewImage
Dim SCR&, W, H, SQUARTER&
SCR& = _ScreenImage
W = _Width(SCR&) / 2
H = _Height(SCR&) / 2
SQUARTER& = _NewImage(W, H, 32)
_PutImage , SCR&, SQUARTER&, (0, 0)-(W - 1, H - 1)
Cls
_PutImage , SQUARTER&, 0
Print SCR&, W, H, SQUARTER&
End Sub
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 346
Threads: 45
Joined: Jun 2024
Reputation:
32
If @BPlus says it works then (as far as im concerned) IT WORKS! I've grown enough now (maturity!) to accept i dont know everything!
If you guys dont figure it out then call upon the gods (Steve, Pete, dBox, Petr) and they will help you!
john
|