Interface Image
-
- All Superinterfaces:
Bounded
public interface Image extends Bounded
Represents an image found in aPage.- Since:
- v3.0
- Version:
- ©2004-2025 Snowtide
- See Also:
Page.getImages()
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classImage.FormatAn enumeration of the different formats in whichimage datamay be produced, as indicated bydataFormat().
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BufferedImagebitmap()Returns aBufferedImagefor thisImagethat is ready to be drawn to a graphics context.RegionbitmapBounds()Returns aRegionwhose width and height indicate that of the bitmap itself; its origin coordinates (Region.lx()andRegion.by()) will always be0, 0.byte[]data()Returns the data for this image, encoded according to the format indicated bydataFormat(); may returnnullif it is known that the image's data cannot be decoded without producing an exception.Image.FormatdataFormat()Returns the format of the image data available from this image'sdata()method.Stringid()Returns the identifier associated with this image's bitmap data, guaranteed to be unique within the scope of its source document.
-
-
-
Method Detail
-
bitmap
BufferedImage bitmap() throws IOException
Returns aBufferedImagefor thisImagethat is ready to be drawn to a graphics context. This method may returnnullif it is known that the image's data cannot be decoded without producing an exception, or if the image'sdataFormat()isJPX / JPEG2000.Note for .NET developers
TheBufferedImageobject returned from this method provides a.getBitmap()method that efficiently produces a .NETSystem.Drawing.Bitmapobject. So, the pattern you'd typically use withbitmap()is e.g.:Page page = pdf.getPage(0); Image image = page.getImages().get(0).bitmap(); if (image != null) { System.Drawing.Bitmap bmp = image.getBitmap(); // ...code continues... }- Throws:
IOException
-
bitmapBounds
Region bitmapBounds()
Returns aRegionwhose width and height indicate that of the bitmap itself; its origin coordinates (Region.lx()andRegion.by()) will always be0, 0.This does not represent the apparent bounds of the image when positioned on the page; use
Bounded.bounds()for that.
-
data
byte[] data() throws IOExceptionReturns the data for this image, encoded according to the format indicated bydataFormat(); may returnnullif it is known that the image's data cannot be decoded without producing an exception.- Throws:
IOException
-
dataFormat
Image.Format dataFormat()
Returns the format of the image data available from this image'sdata()method.
-
id
String id()
Returns the identifier associated with this image's bitmap data, guaranteed to be unique within the scope of its source document.PDF documents can display the same bitmap multiple times; for example, an image that appears in the header of every page is very likely to be encoded once, and then just referenced at each point of usage. Though PDFxStream produces an different
Imageinstance for each image shown in a PDF document, it:- ensures that images that reference the same encoded bitmap data will have the same
id - retrieves and decodes that bitmap data only when necessary, i.e. when
bitmap()anddata()are called
Together, this means that you can access all of the
Images on a page or in a document, and gain easy, efficient access to their apparentBounded.bounds()on the page, but then never decode the same bitmap data more than once: just track eachImage'sid, and reuse thedata()orbitmap()objects for any duplicateids you find. - ensures that images that reference the same encoded bitmap data will have the same
-
-