Code archives/Graphics/Image Packer
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
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. | |||||
Print "Please Enter The Folder Of Images To Pack - " folder$ = Input$() num$ = Input$("Enter Number Of Images - ") numr$ = Input$("Enter Number Of Rows - ") numc$ = Input$("Enter Number Of Cols - ") If FileType(folder$) <> 2 Then RuntimeError "Error: Invalid Input" EndIf myDir = ReadDir(folder$) packed = CreateImage((Int(num$)/Int(numr$))*96,(Int(num$)/Int(numc$))*96) r% = 0 c% = 0 SetBuffer ImageBuffer(packed) Repeat Print "1" file$ = NextFile$(myDir) Print "2" If file$ = "" Then Exit EndIf If FileType(folder$+"\"+file$) = 0 Then Exit EndIf If Not file$ = "." Then If Not file$ = ".." Then image = LoadImage(folder$+"\"+file$) DrawImage image,c,r FreeImage image If c+96 >= (Int(num$)/Int(numr$))*96 Then c = 0 r = r + 96 Else c = c + 96 EndIf EndIf EndIf Forever SaveImage packed,folder$+"\packed.bmp" CloseDir myDir FreeImage packed |
Comments
None.
Code Archives Forum