/** * Return 24 byte header which preceeds the actual picture data. * <p> * The header consists of 2-byte signature, 2-byte type, * 4-byte image size and 16-byte checksum of the image data. * </p> * * @return the 24 byte header which preceeds the actual picture data. */ public byte[] getHeader() { byte[] header = new byte[16 + 8]; LittleEndian.putInt(header, 0, getSignature()); LittleEndian.putInt(header, 4, getRawData().length); System.arraycopy(rawdata, 0, header, 8, 16); return header; }
/** * 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); }
/** * Add a new picture to this presentation. * * @return offset of this picture in the Pictures stream */ public int addPicture(HSLFPictureData img) { // Process any existing pictures if we haven't yet if (_pictures == null) { try { readPictures(); } catch (IOException e) { throw new CorruptPowerPointFileException(e.getMessage()); } } // Add the new picture in int offset = 0; if (_pictures.size() > 0) { HSLFPictureData prev = _pictures.get(_pictures.size() - 1); offset = prev.getOffset() + prev.getRawData().length + 8; } img.setOffset(offset); img.setIndex(_pictures.size() + 1); _pictures.add(img); return offset; }
bse.setRecordId(EscherBSERecord.RECORD_ID); bse.setOptions((short) (0x0002 | (format.nativeId << 4))); bse.setSize(pict.getRawData().length + 8); byte[] uid = HSLFPictureData.getChecksum(data); bse.setUid(uid);