FileDocCategorySizeDatePackage
EMF.javaAPI DocApache Poi 3.0.13303Thu May 31 18:45:28 BST 2007org.apache.poi.hslf.blip

EMF

public class EMF extends Metafile
Represents EMF (Windows Enhanced Metafile) picture data.
author
Yegor Kozlov

Fields Summary
Constructors Summary
Methods Summary
public byte[]getData()
Extract compressed EMF data from a ppt

        try {
            byte[] rawdata = getRawData();

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            InputStream is = new ByteArrayInputStream( rawdata );
            Header header = new Header();
            header.read(rawdata, CHECKSUM_SIZE);
            is.skip(header.getSize() + CHECKSUM_SIZE);

            InflaterInputStream inflater = new InflaterInputStream( is );
            byte[] chunk = new byte[4096];
            int count;
            while ((count = inflater.read(chunk)) >=0 ) {
                out.write(chunk,0,count);
            }
            inflater.close();
            return out.toByteArray();
        } catch (IOException e){
            throw new HSLFException(e);
        }
    
public intgetSignature()
EMF signature is 0x3D40

return
EMF signature (0x3D40)

        return 0x3D40;
    
public intgetType()

        return Picture.EMF;
    
public voidsetData(byte[] data)

        byte[] compressed = compress(data, 0, data.length);

        Header header = new Header();
        header.wmfsize = data.length;
        //we don't have a EMF 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);
        header.write(out);
        out.write(compressed);

        setRawData(out.toByteArray());