Create image from Data by Dewi Morgan2nd Mar 2008 12:15
|
---|
Summary Very simple but handy li'l function to read in RGB triplets from data statements, and make an X*Y image from them, via a memblock. Very handy for making medialess programs. Description Very simple but handy li'l function to read in RGB triplets from data statements, and make an X*Y image from them, via a memblock. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` License: Public Domain function ReadImageFromData(X,Y) ImageID find free image() MemblockID = find free memblock() make memblock MemblockID, 4+4+4+(4*X*Y) write memblock dword MemblockID, 0, X ` Width write memblock dword MemblockID, 4, Y ` Height write memblock dword MemblockID, 8, 32 ` BitDepth for i = 12 to 12 + 4*X*Y - 1 step 4 read r : read g : read b write memblock byte MemblockID, i, b ` Stored in reverse. write memblock byte MemblockID, i+1, g write memblock byte MemblockID, i+2, r write memblock byte MemblockID, i+3, 255 next i make image from memblock ImageID, MemblockID delete memblock MemblockID endfunction ImageID |