Code archives/Graphics/Convert Images to Code
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This program can be used to convert any image to code, including animated images. With very large images sometimes the program doesn't automatically close. If the file is already created then it has worked successfully. You can also normally tell if it is done based on the sound of the computer. I hope that this is useful to someone. | |||||
location$ = Input$("Enter file location: ") name$ = Input$("Enter file name: ") maskred$ = Input$("Redmask: ") maskgreen$ = Input$("Greenmask: ") maskblue$ = Input$("Bluemask: ") frames = Input$("Frames: ") GlobalYesOrNo = Input$("Global 1 for yes, 0 for no: ") frame = 0 xspot = 0 image = LoadImage (location$) width = ImageWidth (image) height = ImageHeight (image) fwidth = width/frames x = 0 y = 0 draw = CreateImage(width,height) SetBuffer ImageBuffer(draw) DrawImage image,0,0 save=WriteFile(name$+".bb") If GlobalYesOrNo = "1" Then WriteLine save,"Global "+name$+" = "+"CreateImage("+fwidth+","+height+","+frames+")" If GlobalYesOrNo = "0" Then WriteLine save,name$+" = "+"CreateImage("+fwidth+","+height+","+frames+")" WriteLine save,"SetBuffer ImageBuffer("+name$+","+frame+")" Repeat GetColor x,y WriteLine save,"Color "+ColorRed()+","+ColorGreen()+","+ColorBlue() WriteLine save,"Plot "+xspot+","+y y = y + 1 If y > height y = 0 xspot = xspot + 1 x = x + 1 If xspot > fwidth - 1 frame = frame + 1 If frame = frames x = width y = height EndIf xspot = 0 If Not x = width And y = height WriteLine save,"SetBuffer ImageBuffer("+name$+","+frame+")" EndIf EndIf EndIf Until x => width And y => height .exitloop WriteLine save,"MaskImage "+name$+","+maskred$+","+maskgreen$+","+maskblue$ CloseFile save End |
Comments
None.
Code Archives Forum