Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_NEWIMAGE can't accept variables as dimensions?
#11
Lol, so the ' On line 2 is the cause of the woes!?
Reply
#12
There are lots of ways to get an illegal Function Call. Could be problem sharing variables with subs and likely is unrelated to using variables in _NewImage because I just showed that works ok, don't assume that is the only way to get an Illegal Function call.

(02-17-2026, 02:34 AM)Unseen Machine Wrote: Lol, so the ' On line 2 is the cause of the woes!?

I had to delete that because it was flagging line 5, me doing a line without a graphics screen.
 At first I though it was flagging the _NewImage line , but no... Sad
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#13
@BPlus - We have resolved the question though right?
Reply
#14
I am satisified _NewImage works fine using variables. It is classic hair puller when you misdiagnose the problem you are having with QB64. Until the problem is resolved, you can not assume you know the cause, that is a hard lesson.

It really does help when you can look at the code. Sometimes other people can see stuff jump right out that OP overlooks over and over again!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#15
Note that you have to use a value greater than 0 and less than 32000. Windows doesn’t support screens larger than this.  

I’d check first variable name, value, ect.  It may be a simple typo or such screwing you up.  iy autocorrected to yi or such.  LOL!

You could also see that type error if $CONSOLE:ONLY is in place.  Otherwise, there’s not a lot of things that can go wrong with that simple command.
Reply
#16
Option _Explicit is great for catching typos, my first goto when something aint working when it's suppose to.
 I even resorted to that testing _NewImage because my screen shot wasn't coming up, but no, I got source and destination backwards! on the PutImage to dest 0.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#17
Quote:The iy values start at 16 and can be increased but never reduced.
 is it possible iy exceeded 32000+ limit for integers? which would make it go negative.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#18
Did you ever get stuck on a word that is wrong one but damned if you can access the correct one.
I am that way with Alchemy, Phil's Game, I get stuck on algorithm.

It's like that with coding problems, you get stuck with idea you are sure is causing the problem but it's not, it's some dumb other thing you aren't seeing.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#19
I found a solution:

In my program I have a UDT which included a LONG value to hold an image handle:

Code: (Select All)
TYPE sigface
    x AS INTEGER 'coords of upper left corner of top section
    y AS INTEGER
    dir AS INTEGER 'orientation direction
    num AS INTEGER 'number of sections
    style AS INTEGER 'straight or cluster
    face AS LONG 'handle to the face image
    'for the next two variables, the digits refer to an index into the Sections array
    sections AS STRING 'string of digits storing the section image indexes
    lit AS STRING 'string of digits storing which sections are lit and which are not
END TYPE

DIM SHARED AS sigface Heads(4,4)



So, the call looked like this:

Head(a,b).face = _NEWIMAGE(64, ix, 32)

Apparently, _NEWIMAGE didn't like returning the handle to a UDT member. When I revised the code to break the images to their own simple array of LONG, _NEWIMAGE was happy. This worked:

Code: (Select All)
 TYPE sigface
    x AS INTEGER 'coords of upper left corner of top section
    y AS INTEGER
    dir AS INTEGER 'orientation direction
    num AS INTEGER 'number of sections
    style AS INTEGER 'straight or cluster
    'for the next two variables, the digits refer to an index into the Sections array
    sections AS STRING 'string of digits storing the section image indexes
    lit AS STRING 'string of digits storing which sections are lit and which are not
END TYPE

DIM SHARED AS sigface Heads(4,4)
DIM SHARED AS LONG lenses(4,4)

lenses(dir, head) = _NEWIMAGE(16, ix, 32)

I can't say whether or not this is expected behavior, but it got me over that hump.

P.S. I always use OPTION _EXPLICIT
It's not the having, it's the doing.
Reply
#20
I don't know, you might have misdiagnosed again. Here I output the _NewImage handle to an UDT Object Type just fine!
Code: (Select All)
Option _Explicit
Type object
    As Long img, wide, high
End Type

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
Dim test As object
testNewImage test
Print test.img, test.wide, test.high


Sub testNewImage (outputObj As object)
    Dim SCR&
    SCR& = _ScreenImage
    outputObj.wide = _Width(SCR&) / 2
    outputObj.high = _Height(SCR&) / 2

    outputObj.img = _NewImage(outputObj.wide, outputObj.high, 32)

    _PutImage , SCR&, outputObj.img, (0, 0)-(outputObj.wide - 1, outputObj.high - 1)
    Cls
    _PutImage , outputObj.img, 0
End Sub

And used object type properties for the variable arguments ta boot!

This
Code: (Select All)
Head(a,b).face = _NEWIMAGE(64, ix, 32)
looks like an attempt to use an UDT array, which as we know can't be done with QB64.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting mouse to ignore outside of _NewImage PhilOfPerth 11 737 12-18-2025, 07:20 PM
Last Post: Pete
  getting the number of dimensions in an array on the fly? madscijr 7 745 09-16-2025, 12:34 AM
Last Post: madscijr
  Why are SINGLE variables faster than INTEGER variables ? Elzaimer 18 2,373 07-07-2025, 05:01 AM
Last Post: ahenry3068
  Why do FOR/NEXT variables end up +1 more? Dav 14 2,892 08-26-2023, 09:25 PM
Last Post: Kernelpanic

Forum Jump:


Users browsing this thread: 1 Guest(s)