Class WmfDecoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.wmf.WmfDecoder
All Implemented Interfaces:
com.idrsolutions.image.Decoder

public class WmfDecoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Decoder
Class reads WMF images as BufferedImage. Make NO assumptions about the type of BufferedImage type returned (it may change)

Example 1 (Using raw byte data):


 WmfDecoder decoder = new WmfDecoder();
 BufferedImage decodedImage = decoder.read(wmfByteData);
 
Example 2 (Using File):

 File wmfFile = new File("C:\\path\\to\\output\\file.png");
 WmfDecoder decoder = new WmfDecoder();
 BufferedImage decodedImage = decoder.read(wmfFile);
 
  • Field Summary

    Fields inherited from class com.idrsolutions.image.JDeliImage

    bb
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isReadable(byte[] wmfRawData)
    Checks whether the wmf image data can be decoded, by validating its structure without decoding the pixels
    boolean
    isReadable(File imageFile)
    Checks whether the wmf image file can be decoded, by validating its structure without decoding the pixels
    read(byte[] data)
     
    read(File file)
    Decodes and returns the WMF file as a BufferedImage from a file
    readDimension(byte[] wmfRawData)
    Decodes and returns the width and height of wmf image
    Decodes and returns the width and height of wmf image
    static void
    toSVG(FileInputStream wmfInputStream, FileOutputStream svgOutputFile)
    Converts WMF data from a stream to SVG and writes it to a stream.
    static void
    toSVG(File wmfFile, File svgOutputFile)
    Converts a WMF file to SVG and writes it to a file.

    Methods inherited from class com.idrsolutions.image.JDeliImage

    optimiseImage

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.idrsolutions.image.Decoder

    getImageCount, getImageCount, readEmbeddedThumbnail, readEmbeddedThumbnail, readImageAt, readImageAt, readImageSpecificMetaData, readImageSpecificMetaData, setMetadata
  • Constructor Details

    • WmfDecoder

      public WmfDecoder()
  • Method Details

    • read

      public BufferedImage read(File file) throws IOException
      Decodes and returns the WMF file as a BufferedImage from a file
      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      file - input image file to be decoded
      Returns:
      BufferedImage decoded image
      Throws:
      IOException - if an error occurs in reading image
    • read

      public BufferedImage read(byte[] data) throws Exception
      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Throws:
      Exception
    • readDimension

      public Rectangle readDimension(File file) throws Exception
      Decodes and returns the width and height of wmf image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      file - image image contained in raw data if present
      Returns:
      width and height of image
      Throws:
      Exception - if problem reading image
    • readDimension

      public Rectangle readDimension(byte[] wmfRawData) throws Exception
      Decodes and returns the width and height of wmf image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      wmfRawData - image image contained in raw data if present
      Returns:
      Rectangle width and height of image
      Throws:
      Exception - if problem reading image
    • isReadable

      public boolean isReadable(byte[] wmfRawData) throws Exception
      Checks whether the wmf image data can be decoded, by validating its structure without decoding the pixels
      Specified by:
      isReadable in interface com.idrsolutions.image.Decoder
      Parameters:
      wmfRawData - wmf image data
      Returns:
      true if the image can be decoded
      Throws:
      Exception - if problem reading image
    • isReadable

      public boolean isReadable(File imageFile) throws Exception
      Checks whether the wmf image file can be decoded, by validating its structure without decoding the pixels
      Specified by:
      isReadable in interface com.idrsolutions.image.Decoder
      Parameters:
      imageFile - wmf image file
      Returns:
      true if the image can be decoded
      Throws:
      Exception - if problem reading image
    • toSVG

      public static void toSVG(File wmfFile, File svgOutputFile) throws IOException
      Converts a WMF file to SVG and writes it to a file.
      Parameters:
      wmfFile - WMF file to convert
      svgOutputFile - file to write the SVG to
      Throws:
      IOException - if the WMF file cannot be read or the SVG cannot be written
    • toSVG

      public static void toSVG(FileInputStream wmfInputStream, FileOutputStream svgOutputFile) throws IOException
      Converts WMF data from a stream to SVG and writes it to a stream. The data is copied to a temporary file, which is deleted afterwards. Both streams are closed by this method.
      Parameters:
      wmfInputStream - stream containing the WMF data
      svgOutputFile - stream to write the SVG to
      Throws:
      IOException - if the WMF data cannot be read or the SVG cannot be written