February 27, 2021, 03:44:25 AM
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
»
File Utilities
»
[bmx] PNG Header by FlameDuck [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bmx] PNG Header by FlameDuck [ 1+ years ago ] (Read 627 times)
BlitzBot
Jr. Member
Posts: 1
[bmx] PNG Header by FlameDuck [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:39 AM »
Title :
PNG Header
Author :
FlameDuck
Posted :
1+ years ago
Description :
Provides methods to determine if a given file is a PNG file, and which dimensions it has without loading the entire file into memory.
Code :
Code: BlitzMax
Strict
Import
BRL.Stream
Import
BRL.EndianStream
Type
PNGHeader
Field
signiture:
String
Field
chunksize:
Int
Field
chunkID:
String
Field
width:
Int
Field
height:
Int
Const
PNG_ID:
String
=
Chr
(
$89
)
+
Chr
(
$50
)
+
Chr
(
$4E
)
+
Chr
(
$47
)
+
Chr
(
$0D
)
+
Chr
(
$0A
)
+
Chr
(
$1A
)
+
Chr
(
$0A
)
Function
fromFile:PNGHeader
(
url:
Object
)
Local
myStream:TStream = ReadStream
(
url
)
Local
temp:PNGHeader
If
StreamSize
(
myStream
)
>
24
temp =
New
PNGHeader
Local
eStream:TStream = BigEndianStream
(
myStream
)
temp.signiture = ReadString
(
eStream ,
8
)
temp.chunksize = Readint
(
eStream
)
temp.chunkID = ReadString
(
eStream ,
4
)
temp.width = Readint
(
eStream
)
temp.height = Readint
(
eStream
)
CloseStream eStream
EndIf
CloseStream myStream
Return
temp
EndFunction
Method
isPNG:
Int
(
)
If
signiture = PNG_ID
Return
True
EndIf
Return
False
EndMethod
Method
toString:
String
(
)
Local
temp:
String
=
"isPng: "
If
isPNG
(
)
temp:+
"True "
Else
temp:+
"False "
EndIf
temp:+
"Width: "
+ width +
" Height: "
+ height
Return
temp
EndMethod
EndType
Comments :
VP(Posted 1+ years ago)
This would be for max, rather than b3d
VP(Posted 1+ years ago)
Ignore me, I've got a cold.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
File Utilities
»
[bmx] PNG Header by FlameDuck [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal