Esempio n. 1
0
  public void setData(byte[] data) throws IOException {
    int pos = 512; // skip the first 512 bytes - they are MAC specific crap
    byte[] compressed = compress(data, pos, data.length - pos);

    Header header = new Header();
    header.wmfsize = data.length - 512;
    // we don't have a PICT reader in java, have to set default image size  200x200
    header.bounds = new java.awt.Rectangle(0, 0, 200, 200);
    header.size =
        new java.awt.Dimension(
            header.bounds.width * Shape.EMU_PER_POINT, header.bounds.height * Shape.EMU_PER_POINT);
    header.zipsize = compressed.length;

    byte[] checksum = getChecksum(data);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    out.write(checksum);

    out.write(new byte[16]); // 16-byte prefix which is safe to ignore
    header.write(out);
    out.write(compressed);

    setRawData(out.toByteArray());
  }
Esempio n. 2
0
  @Override
  public void setData(byte[] data) throws IOException {
    byte[] compressed = compress(data, 0, data.length);

    NativeHeader nHeader = new NativeHeader(data, 0);

    Header header = new Header();
    header.wmfsize = data.length;
    header.bounds = nHeader.deviceBounds;
    Dimension nDim = nHeader.getSize();
    header.size = new Dimension(Units.toEMU(nDim.getWidth()), Units.toEMU(nDim.getHeight()));
    header.zipsize = compressed.length;

    byte[] checksum = getChecksum(data);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    out.write(checksum);
    if (uidInstanceCount == 2) {
      out.write(checksum);
    }
    header.write(out);
    out.write(compressed);

    setRawData(out.toByteArray());
  }