Class PDInlineImage

  • All Implemented Interfaces:
    COSObjectable, PDImage

    public final class PDInlineImage
    extends Object
    implements PDImage
    An inline image object which uses a special syntax to express the data for a small image directly within the content stream.
    • Constructor Detail

      • PDInlineImage

        public PDInlineImage​(COSDictionary parameters,
                             byte[] data,
                             PDResources resources)
                      throws IOException
        Creates an inline image from the given parameters and data.
        Parameters:
        parameters - the image parameters
        data - the image data
        resources - the current resources
        Throws:
        IOException
    • Method Detail

      • getCOSObject

        public COSBase getCOSObject()
        Description copied from interface: COSObjectable
        Convert this standard java object to a COS object.
        Specified by:
        getCOSObject in interface COSObjectable
        Returns:
        The cos object that matches this Java object.
      • getBitsPerComponent

        public int getBitsPerComponent()
        Description copied from interface: PDImage
        Returns bits per component of this image, or -1 if one has not been set.
        Specified by:
        getBitsPerComponent in interface PDImage
      • setBitsPerComponent

        public void setBitsPerComponent​(int bitsPerComponent)
        Description copied from interface: PDImage
        Set the number of bits per component.
        Specified by:
        setBitsPerComponent in interface PDImage
        Parameters:
        bitsPerComponent - The number of bits per component.
      • setColorSpace

        public void setColorSpace​(PDColorSpace colorSpace)
        Description copied from interface: PDImage
        Sets the color space for this image.
        Specified by:
        setColorSpace in interface PDImage
        Parameters:
        colorSpace - The color space for this image.
      • getHeight

        public int getHeight()
        Description copied from interface: PDImage
        Returns height of this image, or -1 if one has not been set.
        Specified by:
        getHeight in interface PDImage
      • setHeight

        public void setHeight​(int height)
        Description copied from interface: PDImage
        Sets the height of the image.
        Specified by:
        setHeight in interface PDImage
        Parameters:
        height - The height of the image.
      • getWidth

        public int getWidth()
        Description copied from interface: PDImage
        Returns the width of this image, or -1 if one has not been set.
        Specified by:
        getWidth in interface PDImage
      • setWidth

        public void setWidth​(int width)
        Description copied from interface: PDImage
        Sets the width of the image.
        Specified by:
        setWidth in interface PDImage
        Parameters:
        width - The width of the image.
      • getInterpolate

        public boolean getInterpolate()
        Description copied from interface: PDImage
        Returns true if the image should be interpolated when rendered.
        Specified by:
        getInterpolate in interface PDImage
      • setInterpolate

        public void setInterpolate​(boolean value)
        Description copied from interface: PDImage
        Sets the Interpolate flag, true for high-quality image scaling.
        Specified by:
        setInterpolate in interface PDImage
      • getFilters

        public List<String> getFilters()
        Returns a list of filters applied to this stream, or null if there are none.
        Returns:
        a list of filters applied to this stream
      • setFilters

        public void setFilters​(List<String> filters)
        Sets which filters are applied to this stream.
        Parameters:
        filters - the filters to apply to this stream.
      • setDecode

        public void setDecode​(COSArray decode)
        Description copied from interface: PDImage
        Sets the decode array.
        Specified by:
        setDecode in interface PDImage
        Parameters:
        decode - the new decode array.
      • getDecode

        public COSArray getDecode()
        Description copied from interface: PDImage
        Returns the decode array.
        Specified by:
        getDecode in interface PDImage
      • isStencil

        public boolean isStencil()
        Description copied from interface: PDImage
        Returns true if the image is a stencil mask.
        Specified by:
        isStencil in interface PDImage
      • setStencil

        public void setStencil​(boolean isStencil)
        Description copied from interface: PDImage
        Sets whether or not the image is a stencil. This corresponds to the ImageMask entry in the image stream's dictionary.
        Specified by:
        setStencil in interface PDImage
        Parameters:
        isStencil - True to make the image a stencil.
      • createInputStream

        public InputStream createInputStream()
                                      throws IOException
        Description copied from interface: PDImage
        Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject.
        Specified by:
        createInputStream in interface PDImage
        Returns:
        Decoded stream\
        Throws:
        IOException - if the data could not be read.
      • createInputStream

        public InputStream createInputStream​(List<String> stopFilters)
                                      throws IOException
        Description copied from interface: PDImage
        Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject. The given filters will not be decoded.
        Specified by:
        createInputStream in interface PDImage
        Returns:
        Decoded stream
        Throws:
        IOException - if the data could not be read.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: PDImage
        Returns true if the image has no data.
        Specified by:
        isEmpty in interface PDImage
      • getData

        public byte[] getData()
        Returns the inline image data.
      • getImage

        public android.graphics.Bitmap getImage()
                                         throws IOException
        Description copied from interface: PDImage
        Returns the content of this image as a Bitmap with ARGB_888. The size of the returned image is the larger of the size of the image itself or its mask.
        Specified by:
        getImage in interface PDImage
        Returns:
        content of this image as a buffered image.
        Throws:
        IOException
      • getStencilImage

        public android.graphics.Bitmap getStencilImage​(android.graphics.Paint paint)
                                                throws IOException
        Description copied from interface: PDImage
        Returns an ARGB image filled with the given paint and using this image as a mask.
        Specified by:
        getStencilImage in interface PDImage
        Parameters:
        paint - the paint to fill the visible portions of the image with
        Returns:
        a masked image filled with the given paint
        Throws:
        IOException - if the image cannot be read
      • getColorKeyMask

        public COSArray getColorKeyMask()
        Returns the color key mask array associated with this image, or null if there is none.
        Returns:
        Mask Image XObject
      • getSuffix

        public String getSuffix()
        Returns the suffix for this image type, e.g. jpg/png.
        Specified by:
        getSuffix in interface PDImage
        Returns:
        The image suffix.