43 |
|
|
44 |
int width=-1, height=-1; |
int width=-1, height=-1; |
45 |
|
|
46 |
public SimpleImageScroll(StormPool ms, BlockId id) { |
public SimpleImageScroll(Alph alph, Object blockid, String contentType) { |
47 |
super(ms, id); |
super(alph, blockid, contentType); |
|
try { |
|
|
ms.request(id, null); |
|
|
} catch(IOException e) { |
|
|
throw new Error("Couldn't load image block"); |
|
|
} |
|
48 |
} |
} |
49 |
|
|
50 |
public boolean equals(Object o) { |
public boolean equals(Object o) { |
57 |
} |
} |
58 |
|
|
59 |
private void loadImageSize() { |
private void loadImageSize() { |
60 |
|
int ind = contentType.indexOf('/'); |
61 |
String ct = msid.getContentType(); |
int ind2 = contentType.indexOf(';'); |
62 |
|
if(ind2 < 0) ind2 = contentType.length(); |
63 |
|
|
64 |
if(!ct.substring(0,ct.indexOf('/')).equals("image")) |
String type = contentType.substring(0,ind); |
65 |
throw new Error("Block isn't an image"); |
String subtype = contentType.substring(ind+1, ind2); |
66 |
|
|
67 |
|
if(!type.equals("image")) |
68 |
|
throw new Error("Image Block isn't an image"); |
69 |
|
|
70 |
Block block ; |
Block block ; |
71 |
Dimension d; |
Dimension d; |
72 |
|
|
73 |
try { |
try { |
74 |
block = ms.get(msid); |
java.io.InputStream is = alph.getBlockInputStream(this); |
|
java.io.InputStream is = block.getInputStream(); |
|
75 |
d = org.nongnu.navidoc.util.ImageSize.readSize(is); |
d = org.nongnu.navidoc.util.ImageSize.readSize(is); |
76 |
if(d == null) |
if(d == null) |
77 |
throw new Error("Couldn't get size of image block"); |
throw new Error("Couldn't get size of image block"); |