March 01, 2021, 11:08:31 PM

Author Topic: [bb] Convert Images to Code by Petron [ 1+ years ago ]  (Read 439 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Convert Images to Code by Petron [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Convert Images to Code
Author : Petron
Posted : 1+ years ago

Description : 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.

Code :
Code: BlitzBasic
  1. location$ = Input$("Enter file location: ")
  2. name$ = Input$("Enter file name: ")
  3. maskred$ = Input$("Redmask: ")
  4. maskgreen$ = Input$("Greenmask: ")
  5. maskblue$ = Input$("Bluemask: ")
  6. frames = Input$("Frames: ")
  7. GlobalYesOrNo = Input$("Global 1 for yes, 0 for no: ")
  8. frame = 0
  9. xspot = 0
  10. image = LoadImage (location$)
  11. width = ImageWidth (image)
  12. height = ImageHeight (image)
  13. fwidth = width/frames
  14. x = 0
  15. y = 0
  16. draw = CreateImage(width,height)
  17. SetBuffer ImageBuffer(draw)
  18. DrawImage image,0,0
  19. save=WriteFile(name$+".bb")
  20. If GlobalYesOrNo = "1" Then WriteLine save,"Global "+name$+" = "+"CreateImage("+fwidth+","+height+","+frames+")"
  21. If GlobalYesOrNo = "0" Then WriteLine save,name$+" = "+"CreateImage("+fwidth+","+height+","+frames+")"
  22. WriteLine save,"SetBuffer ImageBuffer("+name$+","+frame+")"
  23. Repeat
  24. GetColor x,y
  25. WriteLine save,"Color "+ColorRed()+","+ColorGreen()+","+ColorBlue()
  26. WriteLine save,"Plot "+xspot+","+y
  27. y = y + 1
  28. If y > height  
  29. y = 0  
  30. xspot = xspot + 1
  31. x = x + 1
  32. If xspot > fwidth - 1
  33. frame = frame + 1
  34. If frame = frames
  35. x = width
  36. y = height
  37. EndIf  
  38. xspot = 0
  39. If Not x = width And y = height
  40. WriteLine save,"SetBuffer ImageBuffer("+name$+","+frame+")"
  41. EndIf
  42. EndIf
  43. EndIf
  44. Until x => width And y => height
  45. .exitloop
  46. WriteLine save,"MaskImage "+name$+","+maskred$+","+maskgreen$+","+maskblue$
  47. CloseFile save
  48. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal