public void setDefaultSize(){\r
PictureData pict = getPictureData();\r
if (pict instanceof Bitmap){\r
+ BufferedImage img = null;\r
try {\r
- BufferedImage img = ImageIO.read(new ByteArrayInputStream(pict.getData()));\r
- if(img != null) setAnchor(new java.awt.Rectangle(0, 0, img.getWidth(), img.getHeight()));\r
- else setAnchor(new java.awt.Rectangle(0, 0, 200, 200));\r
- } catch (IOException e){\r
- ;\r
+ img = ImageIO.read(new ByteArrayInputStream(pict.getData()));\r
+ } \r
+ catch (IOException e){}\r
+ catch (NegativeArraySizeException ne) {}\r
+ \r
+ if(img != null) {\r
+ // Valid image, set anchor from it\r
+ setAnchor(new java.awt.Rectangle(0, 0, img.getWidth(), img.getHeight()));\r
+ } else {\r
+ // Invalid image, go with the default metafile size\r
+ setAnchor(new java.awt.Rectangle(0, 0, 200, 200));\r
}\r
} else {\r
//default size of a metafile picture is 200x200 \r
\r
Slide slide = ppt.createSlide();\r
File img = new File(cwd, "sci_cec.dib");\r
+ \r
+ // Check we can read the test DIB image\r
+ assertTrue(img.exists());\r
+ \r
+ // Add the image\r
int idx = ppt.addPicture(img, Picture.DIB);\r
Picture pict = new Picture(idx);\r
assertEquals(idx, pict.getPictureIndex());\r