(AGK version: 108.13)
Submitted: 2013-06-14 09:03:22
function img_create_RGBA(www,hhh, klr_r,klr_g,klr_b, klr_a)
`creates an image of 'www' by 'hhh' pixels with defined color

 size = 12 +www *hhh *k4  `memblock 'size' is summary of image width (integer, 4 bytes), image height (integer, 4 bytes), image depth (integer, 4 bytes) - that is 12 bytes - and raw image data (the number of pixels multiplied by 4 bytes)
  mmm = createMemblock(size)

   setMemblockInt(mmm, 0, www)  `writing starts with offset 0
   setMemblockInt(mmm, 4, hhh)  `variable 'www' occupies 4 bytes, so now offset 0 +4 = 4
   setMemblockInt(mmm, 8, 32)   `variable 'hhh' occupies 4 bytes, so now offset 4 +4 = 8

 dec size  `since writing starts with offset 0, it ends at one stage earlier than the memblock 'size'
  for nnn = 12 to size
    setMemblockByte(mmm, nnn, klr_r)
   inc nnn
    setMemblockByte(mmm, nnn, klr_g)
   inc nnn
    setMemblockByte(mmm, nnn, klr_b)
   inc nnn
    setMemblockByte(mmm, nnn, klr_a)
  next nnn

   nnn = createImageFromMemblock(mmm)
    deleteMemblock(mmm)

endfunction nnn
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.