March 01, 2021, 10:29:56 PM

Author Topic: [bb] Image Packer by Luke111 [ 1+ years ago ]  (Read 415 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Image Packer by Luke111 [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Image Packer
Author : Luke111
Posted : 1+ years ago

Description : This code will pack images compatible with blitz into a bitmap. I do not know of too many other programs similar to this, except the image packer in the toolbox, which I tried, but didn't like. Allows you to specify columns, rows, and number of images, as well as folder to grab from. Currently grabs in alphabetical order, and only outputs to a bitmap. Also only works with 96x96. Should be easy to change. This should be good for beginners.

Code :
Code: BlitzBasic
  1. Print "Please Enter The Folder Of Images To Pack - "
  2. folder$ = Input$()
  3. num$ = Input$("Enter Number Of Images - ")
  4. numr$ = Input$("Enter Number Of Rows - ")
  5. numc$ = Input$("Enter Number Of Cols - ")
  6. If FileType(folder$) <> 2 Then
  7.         RuntimeError "Error: Invalid Input"
  8. EndIf
  9. myDir = ReadDir(folder$)
  10. packed = CreateImage((Int(num$)/Int(numr$))*96,(Int(num$)/Int(numc$))*96)
  11. r% = 0
  12. c% = 0
  13. SetBuffer ImageBuffer(packed)
  14. Repeat
  15. Print "1"
  16. file$ = NextFile$(myDir)
  17. Print "2"
  18. If file$ = "" Then
  19.         Exit
  20. EndIf
  21. If FileType(folder$+""+file$) = 0 Then
  22.         Exit
  23. EndIf
  24. If Not file$ = "." Then
  25.         If Not file$ = ".." Then
  26.  
  27. image = LoadImage(folder$+""+file$)
  28. DrawImage image,c,r
  29. FreeImage image
  30. If c+96 >= (Int(num$)/Int(numr$))*96 Then
  31.         c = 0
  32.         r = r + 96
  33. Else
  34.         c = c + 96
  35. EndIf
  36.         EndIf
  37. EndIf
  38. Forever
  39. SaveImage packed,folder$+"packed.bmp"
  40. CloseDir myDir
  41. FreeImage packed


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal