* @throws DocumentException If an error occurs accessing the image content
*/
private byte[][] getImageData(LwgImage image) throws DocumentException
{
final int WMF_PLACEABLE_HEADER_SIZE = 22;
final RtfByteArrayBuffer bab = new RtfByteArrayBuffer();
try {
if(imageType == LwgImage.ORIGINAL_BMP) {
bab.append(MetaDo.wrapBMP(image));
} else {
final byte[] iod = image.getOriginalData();
if(iod == null) {
final InputStream imageIn = image.getUrl().openStream();
if(imageType == LwgImage.ORIGINAL_WMF) { //remove the placeable header first
for(int k = 0; k < WMF_PLACEABLE_HEADER_SIZE; k++) {
if(imageIn.read() < 0) throw new EOFException(MessageLocalization.getComposedMessage("while.removing.wmf.placeable.header"));
}
}
bab.write(imageIn);
imageIn.close();
} else {
if(imageType == LwgImage.ORIGINAL_WMF) {
//remove the placeable header
bab.write(iod, WMF_PLACEABLE_HEADER_SIZE, iod.length - WMF_PLACEABLE_HEADER_SIZE);
} else {
bab.append(iod);
}
}
}
return bab.toByteArrayArray();
} catch(IOException ioe) {
throw new DocumentException(ioe.getMessage());
}
}