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.

AppGameKit Classic Chat / Memblocks in AGK

Author
Message
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 27th Mar 2013 22:14
So I've been reading through the forums, and I noticed that the newest beta of AppGameKit offers Memblock access. I've never used memblocks before in DB Pro, so they're a completely new world for me. What I do know, however, is that they offer direct access to an image's raw data.

I read through some postings - and Cliff's image shrinker was quite informative - but I'm wondering how to manually change a pixel in an image. His code copies an image color from another part of the image. Let's say I wanted to replace a pixel at X, Y with pure white (RGBA 255,255,255,255)?

I saw how to split the byte to get the color parts but not the other way around, and I'm not sure how much code from DB can carry over to the AppGameKit world.

Thank you!

Hi there. My name is Dug. I have just met you, and I love you.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Mar 2013 22:42 Edited at: 27th Mar 2013 22:49
there are no direct image access. please correct me if i wrote wrong.

you can made a memblock from image, change a r,g,b,a (4 bytes) value and
make a image again. i think its not for realtime and not a direct access but usefuly for other things.
the memblock have a header with image size etc.

the functions in beta now:
CreateImageFromMemblock
CreateMemblock
CreateMemblockFromImage
DeleteMemblock
GetMemblockByte
GetMemblockExists
GetMemblockFloat
GetMemblockInt
GetMemblockShort
GetMemblockSize
SetMemblockByte
SetMemblockFloat
SetMemblockInt
SetMemblockShort


anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 27th Mar 2013 23:02
Ooh that code snippit helps a lot! Thank you! And memblocks are the closest access to direct image manipulation we'll come across (better than nothing though!)

Hi there. My name is Dug. I have just met you, and I love you.
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 28th Mar 2013 21:18
So I'm attempting this code to create a 512x512 Memblock and it's not working.

creatememblock(1, 1048588)
Setmemblockint(1, 0, 512)
Setmemblockint(1, 4, 512)
CreateImageFromMemblock(1, 1)

It crashes :/ Is there something I'm doing wrong? I think the Memblock is big enough and I'm trying to store the image size in it too at the first few bytes. Any ideas?

Hi there. My name is Dug. I have just met you, and I love you.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Mar 2013 22:07
the header is 12 bytes Width/Height/ColorDepth
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 28th Mar 2013 22:24
Yup! (512 x 512 x 4) + 12 = 1048588. The color depth is assumed to be 32 any way, right? I wonder if the DB forums could be of assistance

Hi there. My name is Dug. I have just met you, and I love you.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 28th Mar 2013 22:58 Edited at: 28th Mar 2013 22:59
You need to set the colour depth also:



Login to post a reply

Server time is: 2024-11-24 09:22:23
Your offset time is: 2024-11-24 09:22:23