public ImageHeaderWMF(byte[] data, final int off) { int offset = off; int key = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; //header key if (key != APMHEADER_KEY) { LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing"); handle = 0; left = 0; top = 0; right = 200; bottom = 200; inch = Units.POINT_DPI; //default resolution is 72 dpi reserved = 0; return; } handle = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; left = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; top = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; right = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; bottom = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; inch = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; reserved = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; checksum = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; if (checksum != getChecksum()){ LOG.log(POILogger.WARN, "WMF checksum does not match the header data"); } }
/** * get an unsigned int value from a byte array * * @param data * the byte array * @return the unsigned int (32-bit) value in a long */ public static long getUInt( byte[] data ) { return getUInt( data, 0 ); }
/** * Reads the 8 byte header information and populates the <code>options</code> * and <code>recordId</code> records. * * @param data the byte array to read from * @param offset the offset to start reading from * @return the number of bytes remaining in this record. This * may include the children if this is a container. */ protected int readHeader( byte[] data, int offset ) { _options = LittleEndian.getShort( data, offset ); _recordId = LittleEndian.getShort( data, offset + 2 ); return LittleEndian.getInt( data, offset + 4 ); }
if (!(LittleEndian.getShort(data, offset) == DConRefRecord.sid)) throw new RecordFormatException("incompatible sid."); offset += LittleEndian.SHORT_SIZE; firstRow = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; lastRow = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; firstCol = LittleEndian.getUByte(data, offset); offset += LittleEndian.BYTE_SIZE; lastCol = LittleEndian.getUByte(data, offset); offset += LittleEndian.BYTE_SIZE; charCount = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; if (charCount < 2) throw new RecordFormatException("Character count must be >= 2"); charType = LittleEndian.getUByte(data, offset); path = LittleEndian.getByteArray(data, offset, byteLength, MAX_RECORD_LENGTH); offset += byteLength; _unused = LittleEndian.getByteArray(data, offset, (charType + 1), MAX_RECORD_LENGTH);
/** * get an int value from the beginning of a byte array * * @param data * the byte array * @return the int (32-bit) value */ public static int getInt( byte[] data ) { return getInt( data, 0 ); }
/** * get an unsigned short value from the beginning of a byte array * * @param data * the byte array * @return the unsigned short (16-bit) value in an int */ public static int getUShort( byte[] data ) { return getUShort( data, 0 ); }
LittleEndian.putUInt(Variant.VT_EMPTY, out); length = LittleEndianConsts.INT_SIZE; break; LittleEndian.putShort( out, ((Number)value).shortValue() ); length = LittleEndianConsts.SHORT_SIZE; LittleEndian.putUShort( ((Number)value).intValue(), out ); length = LittleEndianConsts.SHORT_SIZE; LittleEndian.putInt( ((Number)value).intValue(), out); length = LittleEndianConsts.INT_SIZE; LittleEndian.putUInt( ((Number)value).longValue(), out); length = LittleEndianConsts.INT_SIZE; LittleEndian.putLong( ((Number)value).longValue(), out); length = LittleEndianConsts.LONG_SIZE; if (value instanceof Number) { int floatBits = Float.floatToIntBits(((Number)value).floatValue()); LittleEndian.putInt(floatBits, out); length = LittleEndianConsts.INT_SIZE; LittleEndian.putDouble( ((Number)value).doubleValue(), out); length = LittleEndianConsts.DOUBLE_SIZE;
protected void fillFields( byte[] data, int offset ) { field_1_iStartAt = LittleEndian.getInt( data, 0x0 + offset ); field_2_nfc = data[ 0x4 + offset ]; field_3_info = data[ 0x5 + offset ]; field_4_rgbxchNums = LittleEndian.getByteArray( data, 0x6 + offset,9 ); field_5_ixchFollow = data[ 0xf + offset ]; field_6_dxaIndentSav = LittleEndian.getInt( data, 0x10 + offset ); field_7_unused2 = LittleEndian.getInt( data, 0x14 + offset ); field_8_cbGrpprlChpx = LittleEndian.getUByte( data, 0x18 + offset ); field_9_cbGrpprlPapx = LittleEndian.getUByte( data, 0x19 + offset ); field_10_ilvlRestartLim = LittleEndian.getUByte( data, 0x1a + offset ); field_11_grfhic = new Grfhic( data, 0x1b + offset ); }
int peOffset = LittleEndian.readInt(stream); int machine = LittleEndian.getUShort(pe, 4); int numSectors = LittleEndian.getUShort(pe, 6); long createdAt = LittleEndian.getInt(pe, 8); long symbolTableOffset = LittleEndian.getInt(pe, 12); long numSymbols = LittleEndian.getInt(pe, 16); int sizeOptHdrs = LittleEndian.getUShort(pe, 20); int characteristcs = LittleEndian.getUShort(pe, 22);
public ImageHeaderEMF(final byte data[], final int off) { int offset = off; int type = (int)LittleEndian.getUInt(data, offset); offset += 4; if (type != 1) { LOG.log(POILogger.WARN, "Invalid EMF picture - invalid type"); deviceBounds = new Rectangle(0,0,200,200); return; } // ignore header size offset += 4; int left = LittleEndian.getInt(data, offset); offset += 4; int top = LittleEndian.getInt(data, offset); offset += 4; int right = LittleEndian.getInt(data, offset); offset += 4; int bottom = LittleEndian.getInt(data, offset); offset += 4; deviceBounds = new Rectangle(left, top, right-left, bottom-top); // ignore frame bounds offset += 16; String signature = new String(data, offset, EMF_SIGNATURE.length(), LocaleUtil.CHARSET_1252); if (!EMF_SIGNATURE.equals(signature)) { LOG.log(POILogger.WARN, "Invalid EMF picture - invalid signature"); } }
/** * Build an instance of {@code OEPlaceholderAtom} from on-disk data */ protected OEPlaceholderAtom(byte[] source, int start, int len) { _header = new byte[8]; int offset = start; System.arraycopy(source,start,_header,0,8); offset += _header.length; placementId = LittleEndian.getInt(source, offset); offset += 4; placeholderId = LittleEndian.getUByte(source, offset); offset++; placeholderSize = LittleEndian.getUByte(source, offset); offset++; unusedShort = LittleEndian.getShort(source, offset); }
public HMEFDumper(InputStream inp) throws IOException { this.inp = inp; // Check the signature matches long sig = LittleEndian.readInt(inp); if(sig != HMEFMessage.HEADER_SIGNATURE) { throw new IllegalArgumentException( "TNEF signature not detected in file, " + "expected " + HMEFMessage.HEADER_SIGNATURE + " but got " + sig ); } // Skip over the File ID LittleEndian.readUShort(inp); }
/** * get a short value from the beginning of a byte array * * @param data * the byte array * @return the short (16-bit) value */ public static short getShort( byte[] data ) { return getShort( data, 0 ); }
Blob( byte[] data, int offset ) { int size = LittleEndian.getInt( data, offset ); if ( size == 0 ) { _value = new byte[0]; return; } _value = LittleEndian.getByteArray( data, offset + LittleEndian.INT_SIZE, size ); }
public byte[] toByteArray() { byte[] result = new byte[LONG_SIZE]; LittleEndian.putLong( result, 0, fileTime); return result; }
/** * Dumps out a hex value by reading from a input stream. * * @param bytes How many bytes this hex value consists of. * @param in The stream to read the hex value from. * @param out The stream to write the nicely formatted hex value to. */ private void outHex( int bytes, InputStream in, PrintStream out ) throws IOException, LittleEndian.BufferUnderrunException { switch ( bytes ) { case 1: out.print( HexDump.toHex( (byte) in.read() ) ); break; case 2: out.print( HexDump.toHex( LittleEndian.readShort( in ) ) ); break; case 4: out.print( HexDump.toHex( LittleEndian.readInt( in ) ) ); break; default: throw new IOException( "Unable to output variable of that width" ); } }