/** * This method checks if the image is a valid WMF and processes some parameters. * @throws BadElementException * @throws IOException */ private void processParameters() throws BadElementException, IOException { type = IMGTEMPLATE; originalType = ORIGINAL_WMF; InputStream is = null; try { String errorID; if (rawData == null){ is = url.openStream(); errorID = url.toString(); } else{ is = new java.io.ByteArrayInputStream(rawData); errorID = "Byte array"; } InputMeta in = new InputMeta(is); if (in.readInt() != 0x9AC6CDD7) { throw new BadElementException(errorID + " is not a valid placeable windows metafile."); } in.readWord(); int left = in.readShort(); int top = in.readShort(); int right = in.readShort(); int bottom = in.readShort(); int inch = in.readWord(); dpiX = 72; dpiY = 72; scaledHeight = (float)(bottom - top) / inch * 72f; setTop(scaledHeight); scaledWidth = (float)(right - left) / inch * 72f; setRight(scaledWidth); } finally { if (is != null) { is.close(); } plainWidth = getWidth(); plainHeight = getHeight(); } }
/** * This method checks if the image is a valid WMF and processes some parameters. * @throws BadElementException * @throws IOException */ private void processParameters() throws BadElementException, IOException { type = IMGTEMPLATE; originalType = ORIGINAL_WMF; InputStream is = null; try { String errorID; if (rawData == null){ is = url.openStream(); errorID = url.toString(); } else{ is = new java.io.ByteArrayInputStream(rawData); errorID = "Byte array"; } InputMeta in = new InputMeta(is); if (in.readInt() != 0x9AC6CDD7) { throw new BadElementException(errorID + " is not a valid placeable windows metafile."); } in.readWord(); int left = in.readShort(); int top = in.readShort(); int right = in.readShort(); int bottom = in.readShort(); int inch = in.readWord(); dpiX = 72; dpiY = 72; scaledHeight = (float)(bottom - top) / inch * 72f; setTop(scaledHeight); scaledWidth = (float)(right - left) / inch * 72f; setRight(scaledWidth); } finally { if (is != null) { is.close(); } plainWidth = width(); plainHeight = height(); } }