org.foray.graphic
Class JPEGGraphic

java.lang.Object
  extended by org.foray.graphic.Graphic4a
      extended by org.foray.graphic.JPEGGraphic
All Implemented Interfaces:
org.axsl.graphic.Graphic

public class JPEGGraphic
extends Graphic4a

A JPEG image, using Java native classes.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axsl.graphic.Graphic
org.axsl.graphic.Graphic.Compression, org.axsl.graphic.Graphic.Type
 
Field Summary
protected static byte APP0
          Application marker, JFIF.
protected static byte APPF
          Byte value indicating the Application marker.
protected static byte COLOR_DEPTH_MARKER
          Byte value indicating a Color-Depth Marker.
protected static int COLOR_SPACE_CMYK
          Constant used in a JPEG file to indicate that the color-space is CMYK (four channels).
protected static int COLOR_SPACE_GRAY
          Constant used in a JPEG file to indicate that the color-space is grayscale.
protected static int COLOR_SPACE_OFFSET
          The offset, in bytes, to the color space information.
protected static int COLOR_SPACE_RGB
          Constant used in a JPEG file to indicate that the color-space is RGB (three channels).
protected static byte DIMENSION_MARKER
          Byte value indicating a Dimension Marker.
protected static int HEIGHT_OFFSET
          The offset, in bytes, to the height of the image.
protected static int ICC_HEADER_SIZE
          The size, in bytes, of the ICC Header.
protected static byte ICC_MARKER
          Byte value indicating an ICC Marker.
protected static int ICC_MARKER_SIZE
          The size, in bytes, of the ICC Marker.
protected static byte MARK
          Byte value indicating the Beginning of a Marker.
protected static int MINIMUM_ICC_SIZE
          The minimum size, in bytes, of an ICC profile.
protected static byte PHOTOSHOP_MARK
          Application marker?? Photoshop??.
protected static int PHOTOSHOP_OFFSET
          The offset, in bytes, to the Photoshop indicator.
protected static int READ_BUFFER_SIZE
          The size, in bytes, of the read buffer that should be used to read a JPEG file.
protected static byte SOF1
          Baseline DCT.
protected static byte SOF2
          Extended Sequential DCT.
protected static byte SOF3
          Progressive DCT.
protected static byte SOFA
          Progressive DCT.
protected static byte SOI
          Byte value indicating the Start of Image.
protected static byte SOS
          Byte value indicating the Start of Scan.
protected static int WIDTH_OFFSET
          The offset, in bytes, to the width of the image.
 
Fields inherited from class org.foray.graphic.Graphic4a
BIT_DEPTH_4, BIT_DEPTH_COLOR, BIT_DEPTH_GRAYSCALE, BIT_DEPTH_MONOCHROME
 
Constructor Summary
JPEGGraphic(GraphicServer4a server, URL url, BufferedInputStream bis)
          Constructor.
 
Method Summary
 int absoluteHeightReal()
          Returns the absolute height, in millipoints, of the graphic.
 int absoluteWidthReal()
          Returns the absolute width, in millipoints, of the graphic.
 ColorSpace getColorSpace()
           
 org.axsl.graphic.Graphic.Compression getCompressionType()
           
 byte[] getContent()
           
 org.axsl.graphic.Graphic.Type getGraphicType()
           
 String getMimeType()
           
 String getName()
           
 byte[] getRawSamples()
           
 Color getTransparentColor()
           
 boolean isInverted()
           
 boolean isTransparent()
           
 void loadImage()
          Load image data and initialize its properties.
 void parseBasics()
          This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout.
 int pixelHeight()
           Override the Graphic method because, for JPEG, we load the whole image to get its dimensions.
 int pixelWidth()
           Override the Graphic method because, for JPEG, we load the whole image to get its dimensions.
 
Methods inherited from class org.foray.graphic.Graphic4a
absoluteHeight, absoluteWidth, canMakeGraphicOutput, close, getBitDepth, getBitsPerComponent, getContentSize, getGraphicOutput, getInputStream, getLinks, getLogger, getRawColorSpace, getServer, getUrl, isImageLoaded, isValid, loadImageWrapper, maxBytesToParseBasics, parseBasicsWrapper, setBasicsParsed, setBitDepth, setContent, setImageLoaded, setInputStream, setLinks, setValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_BUFFER_SIZE

protected static final int READ_BUFFER_SIZE
The size, in bytes, of the read buffer that should be used to read a JPEG file.

See Also:
Constant Field Values

MARK

protected static final byte MARK
Byte value indicating the Beginning of a Marker.

See Also:
Constant Field Values

SOF1

protected static final byte SOF1
Baseline DCT.

See Also:
Constant Field Values

SOF2

protected static final byte SOF2
Extended Sequential DCT.

See Also:
Constant Field Values

SOF3

protected static final byte SOF3
Progressive DCT. (PDF 1.3 or higher).

See Also:
Constant Field Values

SOFA

protected static final byte SOFA
Progressive DCT. (PDF 1.3 or higher).

See Also:
Constant Field Values

APP0

protected static final byte APP0
Application marker, JFIF.

See Also:
Constant Field Values

PHOTOSHOP_MARK

protected static final byte PHOTOSHOP_MARK
Application marker?? Photoshop??.

See Also:
Constant Field Values

APPF

protected static final byte APPF
Byte value indicating the Application marker.

See Also:
Constant Field Values

SOS

protected static final byte SOS
Byte value indicating the Start of Scan.

See Also:
Constant Field Values

SOI

protected static final byte SOI
Byte value indicating the Start of Image.

See Also:
Constant Field Values

ICC_MARKER

protected static final byte ICC_MARKER
Byte value indicating an ICC Marker.

See Also:
Constant Field Values

DIMENSION_MARKER

protected static final byte DIMENSION_MARKER
Byte value indicating a Dimension Marker.

See Also:
Constant Field Values

COLOR_DEPTH_MARKER

protected static final byte COLOR_DEPTH_MARKER
Byte value indicating a Color-Depth Marker.

See Also:
Constant Field Values

HEIGHT_OFFSET

protected static final int HEIGHT_OFFSET
The offset, in bytes, to the height of the image.

See Also:
Constant Field Values

WIDTH_OFFSET

protected static final int WIDTH_OFFSET
The offset, in bytes, to the width of the image.

See Also:
Constant Field Values

PHOTOSHOP_OFFSET

protected static final int PHOTOSHOP_OFFSET
The offset, in bytes, to the Photoshop indicator.

See Also:
Constant Field Values

COLOR_SPACE_OFFSET

protected static final int COLOR_SPACE_OFFSET
The offset, in bytes, to the color space information.

See Also:
Constant Field Values

COLOR_SPACE_GRAY

protected static final int COLOR_SPACE_GRAY
Constant used in a JPEG file to indicate that the color-space is grayscale.

See Also:
Constant Field Values

COLOR_SPACE_RGB

protected static final int COLOR_SPACE_RGB
Constant used in a JPEG file to indicate that the color-space is RGB (three channels).

See Also:
Constant Field Values

COLOR_SPACE_CMYK

protected static final int COLOR_SPACE_CMYK
Constant used in a JPEG file to indicate that the color-space is CMYK (four channels).

See Also:
Constant Field Values

MINIMUM_ICC_SIZE

protected static final int MINIMUM_ICC_SIZE
The minimum size, in bytes, of an ICC profile.

See Also:
Constant Field Values

ICC_HEADER_SIZE

protected static final int ICC_HEADER_SIZE
The size, in bytes, of the ICC Header.

See Also:
Constant Field Values

ICC_MARKER_SIZE

protected static final int ICC_MARKER_SIZE
The size, in bytes, of the ICC Marker.

See Also:
Constant Field Values
Constructor Detail

JPEGGraphic

public JPEGGraphic(GraphicServer4a server,
                   URL url,
                   BufferedInputStream bis)
Constructor.

Parameters:
server - The parent graphic server.
url - The URL which contains the graphic content.
bis - The reusable input stream containing the bytes from url.
Method Detail

loadImage

public void loadImage()
               throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Load image data and initialize its properties. Subclasses need to implement this method.

Specified by:
loadImage in class Graphic4a
Throws:
org.axsl.graphic.GraphicException - an error occured during loading

getGraphicType

public org.axsl.graphic.Graphic.Type getGraphicType()

getCompressionType

public org.axsl.graphic.Graphic.Compression getCompressionType()

getMimeType

public String getMimeType()

parseBasics

public void parseBasics()
                 throws IOException
Description copied from class: Graphic4a

This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout. This method is responsible to:

  1. store the image's intrinsic width in Graphic.pixelWidth()
  2. store the image's intrinsic height in Graphic.pixelHeight()

The housekeeping work related to resetting the buffer, handling IOExceptions, and managing whether this method should be run are handled elsewhere. In short, this method does not need to address the details handled there.

Specified by:
parseBasics in class Graphic4a
Throws:
IOException - For IO errors during reading of the file.

pixelWidth

public int pixelWidth()
               throws org.axsl.graphic.GraphicException
Override the Graphic method because, for JPEG, we load the whole image to get its dimensions.

Throws:
org.axsl.graphic.GraphicException

pixelHeight

public int pixelHeight()
                throws org.axsl.graphic.GraphicException
Override the Graphic method because, for JPEG, we load the whole image to get its dimensions.

Throws:
org.axsl.graphic.GraphicException

getName

public String getName()

getRawSamples

public byte[] getRawSamples()
                     throws org.axsl.graphic.GraphicException
Throws:
org.axsl.graphic.GraphicException

getContent

public byte[] getContent()
                  throws org.axsl.graphic.GraphicException
Specified by:
getContent in interface org.axsl.graphic.Graphic
Overrides:
getContent in class Graphic4a
Throws:
org.axsl.graphic.GraphicException

absoluteWidthReal

public int absoluteWidthReal()
                      throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Returns the absolute width, in millipoints, of the graphic.

Specified by:
absoluteWidthReal in class Graphic4a
Returns:
The absolute width, in millipoints, of this graphic, if known. If not known, returns -1.
Throws:
org.axsl.graphic.GraphicException - For errors during reading of image file.

absoluteHeightReal

public int absoluteHeightReal()
                       throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Returns the absolute height, in millipoints, of the graphic.

Specified by:
absoluteHeightReal in class Graphic4a
Returns:
The absolute height, in millipoints, of this graphic, if known. If not known, returns -1.
Throws:
org.axsl.graphic.GraphicException - For errors during reading of image file.

isInverted

public boolean isInverted()

getColorSpace

public ColorSpace getColorSpace()
                         throws org.axsl.graphic.GraphicException
Throws:
org.axsl.graphic.GraphicException

isTransparent

public boolean isTransparent()
                      throws org.axsl.graphic.GraphicException
Throws:
org.axsl.graphic.GraphicException

getTransparentColor

public Color getTransparentColor()
                          throws org.axsl.graphic.GraphicException
Throws:
org.axsl.graphic.GraphicException


Copyright © 2017. All rights reserved.