My functions draws a digital display to a memblock then creates an image which I use with sprites. That all works just fine. But I'm trying to save the image as a png and it does nothing. Wasn't even entirely sure where AGK2 stores data since it doesn't make a media folder in My Documents like AppGameKit 1 did, but I found the project directory under steam. I searched my drive for digits.png but found nothing so it's not creating it anywhere. I get no errors.
// Draw digits 0 through 9 to memblock 1
function createDigits()
// Create an image 640x128 with digits of 0 through 9 at 64,128 in size
CreateMemblock(1, 327692)
setMemblockInt(1, 0, 640)
setMemblockInt(1, 4, 128)
setMemblockInt(1, 8, 32)
// width of image
memWidth = 640
c = makecolor(255,255,255)
// The binary representation of each number determines which part of the digital
// display is drawn to make up a given number. 7 bits represent the 7 sides of the
// digital number.
global z as integer[10] = [95,5,118,117,45,121,123,69,127,109]
pos = 0
for i = 0 to 9
for y = 0 to 4
for x = 7+y to 57-y
// top
if z[i] && 64
setMemblockInt(1, (pos+x+(5-y)*memWidth)*4+12, c)
setMemblockInt(1, (pos+x+(5+y)*memWidth)*4+12, c)
endif
// middle
if z[i] && 32
setMemblockInt(1, (pos+x+(64-y)*memWidth)*4+12, c)
setMemblockInt(1, (pos+x+(64+y)*memWidth)*4+12, c)
endif
// bottom
if z[i] && 16
setMemblockInt(1, (pos+x+(123-y)*memWidth)*4+12, c)
setMemblockInt(1, (pos+x+(123+y)*memWidth)*4+12, c)
endif
next x
next y
for x = 0 to 4
for y = 8+x to 61-x
// top-left
if z[i] && 8
setMemblockInt(1, (pos+4-x+y*memWidth)*4+12, c)
setMemblockInt(1, (pos+4+x+y*memWidth)*4+12, c)
endif
// top-right
if z[i] && 4
setMemblockInt(1, (pos+59-x+y*memWidth)*4+12, c)
setMemblockInt(1, (pos+59+x+y*memWidth)*4+12, c)
endif
// bottom-left
if z[i] && 2
setMemblockInt(1, (pos+4-x+(59+y)*memWidth)*4+12, c)
setMemblockInt(1, (pos+4+x+(59+y)*memWidth)*4+12, c)
endif
// bototm-right
if z[i] && 1
setMemblockInt(1, (pos+59-x+(59+y)*memWidth)*4+12, c)
setMemblockInt(1, (pos+59+x+(59+y)*memWidth)*4+12, c)
endif
next y
next x
inc pos, 64
next i
// free memory
undim z[]
// Create the image
CreateImageFromMemblock(1, 1)
DeleteMemblock(1)
// does nothing!
SaveImage(1, "digits.png")
"I like offending people, because I think people who get offended should be offended." - Linus Torvalds