March 01, 2021, 10:29:56 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Image Packer by Luke111 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Image Packer by Luke111 [ 1+ years ago ] (Read 415 times)
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
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...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Image Packer by Luke111 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal