java.lang.Object
org.pentaho.reporting.libraries.pixie.wmf.Buffer
org.pentaho.reporting.libraries.pixie.wmf.MfHeader

public class MfHeader extends Buffer
A buffer which represents a Metafile header.

The meta file header has the following structure

offset length in bytes name meaning
0x00 2 mfType MetaFile type: 0x1 = memory based meta file, 0x2 = disk based meta file
0x02 2 mfHeader length of header in words (16bit)
0x04 2 mfVersion Windows version used to save the file as BCD number. 0x30 for windows 3.0, 0x31 for win3.1 etc.
0x06 4 mfSize File length in words
0x0A 2 mfNoObj maximum number of objects in the file
0x0c 4 mfMaxRec Maximum record length
0x10 2 mfnoPar Not used
  • Field Details

    • QUALITY_NO

      public static final int QUALITY_NO
      A constant stating that the given file is not Wmf-File at all.
      See Also:
    • QUALITY_MAYBE

      public static final int QUALITY_MAYBE
      A constant stating that the given file could be a Wmf-File.
      See Also:
    • QUALITY_YES

      public static final int QUALITY_YES
      A constant stating that the given file is a Wmf-File.
      See Also:
  • Constructor Details

    • MfHeader

      public MfHeader()
  • Method Details

    • isMetafile

      public static int isMetafile(String inName, InputStream in) throws IOException
      Is the given input a metafile? We have to guess by reading the header and/or by looking at the file name.
      Parameters:
      inName - the file name of the stream source
      in - the input stream.
      Returns:
      either QUALITY_NO, QUALITY_MAYBE or QUALITY_YES.
      Throws:
      IOException - if an error occured.
    • read

      public void read(InputStream in) throws IOException
      Read the header from the given input.
      Parameters:
      in - the input stream
      Throws:
      IOException - if an error occured.
    • isValid

      public boolean isValid()
      Returns true if it looks like a real metafile. This implementation does not support Memory-WmfFiles.
      Returns:
      true, if this file is valid, false otherwise.
    • getBBox

      public Rectangle getBBox()
      Return the bounding box of this metafile. This returns an empty (0,0,0,0) rectangle if this file is not placeable.
      Returns:
      the bounding box of the metafile.
    • getUnitsPerInch

      public int getUnitsPerInch()
      Gets the defined resolution, if this is an Aldus-File, null otherwise.
      Returns:
      the image resolution or 0 if not defined.
    • getFileSize

      public int getFileSize()
      Gets the file size of the WmfFile.
      Returns:
      the filesize in bytes.
    • getObjectsSize

      public int getObjectsSize()
      Gets the number of records stored in this metafile.
      Returns:
      the number of records.
    • getMaxRecordSize

      public int getMaxRecordSize()
      Gets the size of the largest Record.
      Returns:
      the maximum record size.
    • getHeaderSize

      public int getHeaderSize()
      Gets the header size.
      Returns:
      the header size.