Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / SetMemblockByte() prob

Author
Message
Slayer_1.0
8
Years of Service
User Offline
Joined: 8th Jan 2016
Location:
Posted: 17th Jan 2016 06:36
I want to be able to control all aspects of memblocks

so I'm trying to write in every byte to a memblock to then make an image from it

but I'm having a prob

adding this code works
SetMemblockInt(1,t,makecolor(0,255,0))


adding this one, not working
red
SetMemblockByte(1,t,0)

green
SetMemblockByte(1,t+1,255)

blue
SetMemblockByte(1,t+2,0)

Alpha
SetMemblockByte(1,t+3,0)



******** not working code
width=getdevicewidth()
height=getdeviceheight()

setvirtualresolution(width,height)

creatememblock(1,12+(width*height*4))

setmemblockint(1,0,width)
setmemblockint(1,4,height)
setmemblockint(1,8,32)

for t=12 to (width*height*4) step 4
setmemblockbyte(1,t,200)
setmemblockbyte(1,t+1,0)
setmemblockbyte(1,t+2,0)
setmemblockbyte(1,t+3,0)
next t

createimagefrommemblock(1,1)
deletememblock(1)

createsprite(1,1)

do

sync()
loop
************not working code




************working code
width=getdevicewidth()
height=getdeviceheight()

setvirtualresolution(width,height)

creatememblock(1,12+(width*height*4))

setmemblockint(1,0,width)
setmemblockint(1,4,height)
setmemblockint(1,8,32)

for t=12 to (width*height*4) step 4
setmemblockint(1,t,makecolor(0,255,0))
next t

createimagefrommemblock(1,1)
deletememblock(1)

createsprite(1,1)

do

sync()
loop

***********working code
Mike Archer
9
Years of Service
User Offline
Joined: 19th Feb 2015
Location: Wales
Posted: 17th Jan 2016 19:11
Integers are stored in little endian format (lowest byte first), when you are writing the bytes individually you are doing it back to front.

Login to post a reply

Server time is: 2024-11-24 13:16:13
Your offset time is: 2024-11-24 13:16:13