String mediaType; switch (pic.getType()) { case EMF: mediaType = "image/emf";
@Override public final String getContentType() { return getType().contentType; }
/** * Write this picture into <code>OutputStream</code> */ public void write(OutputStream out) throws IOException { byte[] data; data = new byte[LittleEndian.SHORT_SIZE]; LittleEndian.putUShort(data, 0, getSignature()); out.write(data); data = new byte[LittleEndian.SHORT_SIZE]; PictureType pt = getType(); LittleEndian.putUShort(data, 0, pt.nativeId + 0xF018); out.write(data); byte[] rd = getRawData(); data = new byte[LittleEndian.INT_SIZE]; LittleEndian.putInt(data, 0, rd.length); out.write(data); out.write(rd); }
public static void main(String args[]) throws IOException { if (args.length < 1) { System.err.println("Usage:"); System.err.println("\tImageExtractor <file>"); return; } HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(args[0])); //extract all pictures contained in the presentation int i = 0; for (HSLFPictureData pict : ppt.getPictureData()) { // picture data byte[] data = pict.getData(); PictureType type = pict.getType(); FileOutputStream out = new FileOutputStream("pict_" + i++ + type.extension); out.write(data); out.close(); } ppt.close(); } }
HSLFPictureShape p = (HSLFPictureShape) shape; HSLFPictureData data = p.getPictureData(); String ext = data.getType().extension; FileOutputStream out = new FileOutputStream("pict-" + picIdx + ext); out.write(data.getData());
String mediaType; switch (pic.getType()) { case EMF: mediaType = "image/emf";
String mediaType; switch (pic.getType()) { case EMF: mediaType = "application/x-emf";