Class CCITTFactory

java.lang.Object
org.sejda.sambox.pdmodel.graphics.image.CCITTFactory

public final class CCITTFactory extends Object
Factory for creating a PDImageXObject containing a CCITT Fax compressed TIFF image.
  • Constructor Details

    • CCITTFactory

      private CCITTFactory()
  • Method Details

    • createFromImage

      public static PDImageXObject createFromImage(BufferedImage image) throws IOException
      Creates a new CCITT group 4 (T6) compressed image XObject from a b/w BufferedImage. This compression technique usually results in smaller images than those produced by LosslessFactory#createFromImage(PDDocument, BufferedImage).
      Parameters:
      image - the image.
      Returns:
      a new image XObject.
      Throws:
      IOException - if there is an error creating the image.
      IllegalArgumentException - if the BufferedImage is not a b/w image.
    • prepareImageXObject

      private static PDImageXObject prepareImageXObject(byte[] byteArray, int width, int height, PDColorSpace initColorSpace) throws IOException
      Throws:
      IOException
    • createFromFile

      public static PDImageXObject createFromFile(File file) throws IOException
      Creates a new CCITT Fax compressed Image XObject from the first page of a TIFF file.
      Parameters:
      file - the TIFF file which contains a suitable CCITT compressed image
      Returns:
      a new Image XObject
      Throws:
      IOException - if there is an error reading the TIFF data.
    • createFromFile

      public static PDImageXObject createFromFile(File file, int number) throws IOException
      Creates a new CCITT Fax compressed Image XObject from the first page of a TIFF file.
      Parameters:
      file - the TIFF file which contains a suitable CCITT compressed image
      number - TIFF image number, starting from 0
      Returns:
      a new Image XObject
      Throws:
      IOException - if there is an error reading the TIFF data.
    • createFromSeekableSource

      public static PDImageXObject createFromSeekableSource(org.sejda.io.SeekableSource source) throws IOException
      Throws:
      IOException
    • createFromSeekableSource

      public static PDImageXObject createFromSeekableSource(org.sejda.io.SeekableSource source, int number) throws IOException
      Throws:
      IOException
    • createFromRandomAccessImpl

      private static PDImageXObject createFromRandomAccessImpl(org.sejda.io.SeekableSource source, int number) throws IOException
      Creates a new CCITT Fax compressed Image XObject from a TIFF file.
      Parameters:
      source - the random access TIFF file which contains a suitable CCITT compressed image
      number - TIFF image number, starting from 0
      Returns:
      a new Image XObject, or null if no such page
      Throws:
      IOException - if there is an error reading the TIFF data.
    • extractFromTiff

      private static org.sejda.io.SeekableSource extractFromTiff(org.sejda.io.SeekableSource source, COSDictionary params, int number) throws IOException
      Throws:
      IOException
    • readshort

      private static int readshort(char endianess, org.sejda.io.SeekableSource source) throws IOException
      Throws:
      IOException
    • readlong

      private static int readlong(char endianess, org.sejda.io.SeekableSource source) throws IOException
      Throws:
      IOException