Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMAGECREATE
#1
How do you use imagecreate if you wanna create a array with more than one index?

Like

DIM Sprite(1, 64) AS USHORT
ttp://hem.passagen.se/qb.basta
Reply
#2
Code:
Dim Sprites(0 To 9) As Any Ptr

For x = 0 To 9
    Sprites(x) = ImageCreate(w, h)
Next x

Put (0, 0), Sprites(1)
Put (0, 0), Sprites(2)
Put (0, 0), Sprites(3)
Put (0, 0), Sprites(4)
Put (0, 0), Sprites(5)
Put (0, 0), Sprites(6)
'....
Reply
#3
Code:
Dim ImgArray(50) as any ptr

ImgArray(10) = IMAGECREATE(10, 10)
ImgArray(20) = IMAGECREATE(100, 10)
ImgArray(21) = IMAGECREATE(10, 100)
ImgArray(22) = IMAGECREATE(100, 100)

IMAGEDESTROY ImgArray(10)
IMAGEDESTROY ImgArray(20)
IMAGEDESTROY ImgArray(21)
IMAGEDESTROY ImgArray(22)
Array size, array indexes and image sizes are just random for the example



EDIT: Damn jofers!
Reply
#4
The deallocation command is "ImageDestroy", not "ImgDestroy", but you are essentially correct.
Reply
#5
Thanks you two, I've also been wondering this same thing. 8)
Reply
#6
Quote:The deallocation command is "ImageDestroy", not "ImgDestroy", but you are essentially correct.
Thanks, fixed.. I always make that misstake.. Tongue ..
Reply
#7
gah! This isn't working for me..

In my engine i use gfx routines that are made using sprites dimed as ushorts..
Using sprites made using IMAGECREATED won't work in them routines.

I however have nothing against doing it manually then this is a totally new question:

I while back i leared that to declare a sprite as ushort in 16 bit mode i would use:
((Wid*Hei*2)+2)

It works fine but i can skip that *2 and it still works so i guess i have done the calucation wrong.

How exactly is it supposed to be?
ttp://hem.passagen.se/qb.basta
Reply
#8
its ( ( ( w * h ) \ 2 ) + 2 )
Reply
#9
Quote:its ( ( ( w * h ) \ 2 ) + 2 )
ONLY if he's using integer. Which he isnt.

QbBasta:
((Wid*Hei*2)+2) is somewhat correct, the size in bytes is:

W*H*2+4 for a 16 or 15bit image, for 24 and 32 it's W*H*4+4, and for 8 or less it's W*H+4

If diming the sprites AS USHORT, then you take the bytesize and divide it by 2

For a 15 or 16bit image, this means:
W*H+2

And as FB start on array index 0:
W*H+1


To use multi dimensional arrays with GET/PUT you can do:
Code:
Dim myArray(10, W*H+1) as USHORT

GET (10, 10)-(20,20), @myArray(0, 0)
GET (100, 10)-(120,20), @myArray(1, 0)
GET (10, 100)-(20,120), @myArray(2, 0)
GET (100, 100)-(120,120), @myArray(3, 0)

PUT (0, 0), @myArray(2, 0), PSET
Reply
#10
oh, my bad.. man.. everytime someone asks someone like this.. i revert back to qb mode and give the answer for 8-bits xP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)