public int init(LittleEndianInputStream leis, int recordSize) throws IOException { leis.mark(10000); // need to read the header to calculate start of bitmap data correct introSize = readHeader(leis); assert(introSize == headerSize); introSize += readColors(leis); assert(introSize < 10000); int fileSize = (headerImageSize < headerSize) ? recordSize : (int)Math.min(introSize+headerImageSize,recordSize); leis.reset(); imageData = IOUtils.toByteArray(leis, fileSize); assert( headerSize != 0x0C || ((((headerWidth * headerPlanes * headerBitCount.flag + 31) & ~31) / 8) * Math.abs(headerHeight)) == headerImageSize); return fileSize; }
public static HwmfPlaceableHeader readHeader(LittleEndianInputStream leis) throws IOException { leis.mark(LittleEndianConsts.INT_SIZE); int magic = leis.readInt(); if (magic == WMF_HEADER_MAGIC) { return new HwmfPlaceableHeader(leis); } else { leis.reset(); return null; } }