Class Picture


  • public final class Picture
    extends java.lang.Object
    Represents embedded picture extracted from Word Document
    • Constructor Summary

      Constructors 
      Constructor Description
      Picture​(int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes)
      Builds a Picture object for a Picture stored in the DataStream
      Picture​(EscherBlipRecord blipRecord)
      Builds a Picture object for a Picture stored as Escher.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getContent()  
      double getCropBottom()
      the location, expressed as a fraction of the image height, of the bottom of the crop rectangle.
      double getCropLeft()
      The location, expressed as a fraction of the image width, of the left side of the crop rectangle.
      double getCropRight()
      the location of the right side, expressed as a fraction of the image width, of the crop rectangle.
      double getCropTop()
      the location, expressed as a fraction of the image height, of the top of the crop rectangle.
      java.lang.String getDescription()
      returns the description stored in the alternative text
      int getDxaCropLeft()  
      int getDxaCropRight()  
      int getDxaGoal()
      Gets the initial width of the picture, in twips, prior to cropping or scaling.
      int getDyaCropBottom()  
      int getDyaCropTop()  
      int getDyaGoal()
      Gets the initial height of the picture, in twips, prior to cropping or scaling.
      int getHeight()
      returns pixel height of the picture or -1 if dimensions determining was failed
      int getHorizontalScalingFactor()  
      java.lang.String getMimeType()
      Returns the MIME type for the image
      byte[] getRawContent()
      Returns picture's content as stored in the Word file, i.e.
      int getSize()  
      int getStartOffset()  
      int getVerticalScalingFactor()  
      int getWidth()
      returns pixel width of the picture or -1 if dimensions determining was failed
      java.lang.String suggestFileExtension()
      tries to suggest extension for picture's file by matching signatures of popular image formats to first bytes of picture's contents
      java.lang.String suggestFullFileName()
      Tries to suggest a filename: hex representation of picture structure offset in "Data" stream plus extension that is tried to determine from first byte of picture's content.
      PictureType suggestPictureType()  
      void writeImageContent​(java.io.OutputStream out)
      Writes Picture's content bytes to specified OutputStream.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Picture

        public Picture​(EscherBlipRecord blipRecord)
        Builds a Picture object for a Picture stored as Escher. TODO We need to pass in the PICF data too somehow!
      • Picture

        public Picture​(int dataBlockStartOfsset,
                       byte[] _dataStream,
                       boolean fillBytes)
        Builds a Picture object for a Picture stored in the DataStream
    • Method Detail

      • getContent

        public byte[] getContent()
        Returns:
        picture's content as byte array
      • getDxaCropLeft

        public int getDxaCropLeft()
        Returns:
        The amount the picture has been cropped on the left in twips
      • getCropLeft

        public double getCropLeft()
        The location, expressed as a fraction of the image width, of the left side of the crop rectangle. A value of 0 specifies that the left side of the image is uncropped. Positive values specify cropping into the image. Negative values specify cropping out from the image. The default value for this property is 0.
        Returns:
        the left crop percent
      • getDxaCropRight

        public int getDxaCropRight()
        Returns:
        The amount the picture has been cropped on the right in twips
      • getCropRight

        public double getCropRight()
        the location of the right side, expressed as a fraction of the image width, of the crop rectangle. A value of 0 specifies that the right side of the image is uncropped. Positive values specify cropping into the image. Negative values specify cropping out from the image. The default value for this property is 0.
        Returns:
        the right crop percent
      • getDxaGoal

        public int getDxaGoal()
        Gets the initial width of the picture, in twips, prior to cropping or scaling.
        Returns:
        the initial width of the picture in twips
      • getDyaCropBottom

        public int getDyaCropBottom()
        Returns:
        The amount the picture has been cropped on the bottom in twips
      • getCropBottom

        public double getCropBottom()
        the location, expressed as a fraction of the image height, of the bottom of the crop rectangle. A value of 0 specifies that the bottom of the image is uncropped. Positive values specify cropping into the image. Negative values specify cropping out from the image. The default value for this property is 0
        Returns:
        the bottom crop percent
      • getDyaCropTop

        public int getDyaCropTop()
        Returns:
        The amount the picture has been cropped on the top in twips
      • getCropTop

        public double getCropTop()
        the location, expressed as a fraction of the image height, of the top of the crop rectangle. A value of 0 specifies that the top of the image is uncropped. Positive values specify cropping into the image. Negative values specify cropping out from the image. The default value for this property is 0.
        Returns:
        the top crop percent
      • getDyaGoal

        public int getDyaGoal()
        Gets the initial height of the picture, in twips, prior to cropping or scaling.
        Returns:
        the initial width of the picture in twips
      • getHeight

        public int getHeight()
        returns pixel height of the picture or -1 if dimensions determining was failed
      • getHorizontalScalingFactor

        public int getHorizontalScalingFactor()
        Returns:
        Horizontal scaling factor supplied by user expressed in .001% units
      • getMimeType

        public java.lang.String getMimeType()
        Returns the MIME type for the image
        Returns:
        MIME-type for known types of image or "image/unknown" if unknown
      • getRawContent

        public byte[] getRawContent()
        Returns picture's content as stored in the Word file, i.e. possibly in compressed form.
        Returns:
        picture's content as it stored in Word file or an empty byte array if it cannot be read.
      • getSize

        public int getSize()
        Returns:
        size in bytes of the picture
      • getStartOffset

        public int getStartOffset()
        Returns:
        The offset of this picture in the picture bytes, used when matching up with CharacterRun.getPicOffset()
      • getVerticalScalingFactor

        public int getVerticalScalingFactor()
        Returns:
        Vertical scaling factor supplied by user expressed in .001% units
      • getWidth

        public int getWidth()
        returns pixel width of the picture or -1 if dimensions determining was failed
      • getDescription

        public java.lang.String getDescription()
        returns the description stored in the alternative text
        Returns:
        pictue description
      • suggestFileExtension

        public java.lang.String suggestFileExtension()
        tries to suggest extension for picture's file by matching signatures of popular image formats to first bytes of picture's contents
        Returns:
        suggested file extension
      • suggestFullFileName

        public java.lang.String suggestFullFileName()
        Tries to suggest a filename: hex representation of picture structure offset in "Data" stream plus extension that is tried to determine from first byte of picture's content.
        Returns:
        suggested file name
      • suggestPictureType

        public PictureType suggestPictureType()
      • writeImageContent

        public void writeImageContent​(java.io.OutputStream out)
                               throws java.io.IOException
        Writes Picture's content bytes to specified OutputStream. Is useful when there is need to write picture bytes directly to stream, omitting its representation in memory as distinct byte array.
        Parameters:
        out - a stream to write to
        Throws:
        java.io.IOException - if some exception is occured while writing to specified out