48 |
ub(b[2]) * 256 + |
ub(b[2]) * 256 + |
49 |
ub(b[3]); |
ub(b[3]); |
50 |
} |
} |
51 |
|
|
52 |
/** Read the size of an image file. |
/** Read the size of an image file. |
53 |
*/ |
*/ |
54 |
static public Dimension readSize(File f) { |
static public Dimension readSize(File f) { |
55 |
try { |
try { |
56 |
FileInputStream is = new FileInputStream(f); |
FileInputStream is = new FileInputStream(f); |
57 |
|
return readSize(is); |
58 |
|
} catch(IOException e) { |
59 |
|
return null; |
60 |
|
} |
61 |
|
} |
62 |
|
|
63 |
|
/** Read the size of an image given an inputstream. |
64 |
|
*/ |
65 |
|
static public Dimension readSize(InputStream is) { |
66 |
|
try { |
67 |
byte[] in = new byte[4]; |
byte[] in = new byte[4]; |
68 |
is.read(in); |
is.read(in); |
69 |
if(ub(in[0]) == 0x89 && |
if(ub(in[0]) == 0x89 && |