Package org.jmrtd.lds
Class AbstractImageInfo
- java.lang.Object
-
- org.jmrtd.lds.AbstractImageInfo
-
- All Implemented Interfaces:
java.io.Serializable
,ImageInfo
,LDSElement
- Direct Known Subclasses:
DisplayedImageInfo
,FaceImageInfo
,FingerImageInfo
,IrisImageInfo
public abstract class AbstractImageInfo extends java.lang.Object implements ImageInfo
Base class for image infos.- Version:
- $Revision: 1808 $
- Author:
- The JMRTD team ([email protected])
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jmrtd.lds.ImageInfo
JPEG_MIME_TYPE, JPEG2000_MIME_TYPE, TYPE_FINGER, TYPE_IRIS, TYPE_PORTRAIT, TYPE_SIGNATURE_OR_MARK, TYPE_UNKNOWN, WSQ_MIME_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractImageInfo(int type)
Constructs an abstract image info with a type.AbstractImageInfo(int type, int width, int height, java.io.InputStream inputStream, long imageLength, java.lang.String mimeType)
Constructs an abstract image info.protected
AbstractImageInfo(int type, java.lang.String mimeType)
Constructs an abstract image info with a type and a mime-type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
byte[]
getEncoded()
Encodes this image info.int
getHeight()
Returns the height of the image.java.io.InputStream
getImageInputStream()
Returns the encoded image as an input stream.int
getImageLength()
Returns the length of the encoded image.java.lang.String
getMimeType()
Returns the mime-type of the encoded image.int
getType()
Returns the content-type, where content-type is one ofImageInfo.TYPE_PORTRAIT
,ImageInfo.TYPE_FINGER
,ImageInfo.TYPE_IRIS
,ImageInfo.TYPE_SIGNATURE_OR_MARK
.int
getWidth()
Returns the width of the image.int
hashCode()
protected void
readImage(java.io.InputStream inputStream, long imageLength)
Clients should call this method after positioning the input stream to the image bytes.protected abstract void
readObject(java.io.InputStream inputStream)
Reads this object from a stream.protected void
setHeight(int height)
Sets the height of this image.protected void
setImageBytes(byte[] imageBytes)
Sets the encoded image bytes of this image.protected void
setMimeType(java.lang.String mimeType)
Sets the mime-type.protected void
setType(int type)
Sets the type.protected void
setWidth(int width)
Sets the width of this image.java.lang.String
toString()
Returns a textual representation of this image info.protected void
writeImage(java.io.OutputStream outputStream)
Writes this image to a stream.protected abstract void
writeObject(java.io.OutputStream outputStream)
Writes this object to a stream.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jmrtd.lds.ImageInfo
getRecordLength
-
-
-
-
Constructor Detail
-
AbstractImageInfo
protected AbstractImageInfo(int type)
Constructs an abstract image info with a type.- Parameters:
type
- the type of image
-
AbstractImageInfo
protected AbstractImageInfo(int type, java.lang.String mimeType)
Constructs an abstract image info with a type and a mime-type.- Parameters:
type
- the typemimeType
- the mime-type string
-
AbstractImageInfo
public AbstractImageInfo(int type, int width, int height, java.io.InputStream inputStream, long imageLength, java.lang.String mimeType) throws java.io.IOException
Constructs an abstract image info.- Parameters:
type
- type of image infowidth
- width of imageheight
- height of imageinputStream
- encoded imageimageLength
- length of encoded imagemimeType
- mime-type of encoded image- Throws:
java.io.IOException
- if reading fails
-
-
Method Detail
-
getType
public int getType()
Returns the content-type, where content-type is one ofImageInfo.TYPE_PORTRAIT
,ImageInfo.TYPE_FINGER
,ImageInfo.TYPE_IRIS
,ImageInfo.TYPE_SIGNATURE_OR_MARK
.
-
getMimeType
public java.lang.String getMimeType()
Returns the mime-type of the encoded image.- Specified by:
getMimeType
in interfaceImageInfo
- Returns:
- the mime-type of the encoded image
-
getWidth
public int getWidth()
Returns the width of the image.
-
getHeight
public int getHeight()
Returns the height of the image.
-
getImageLength
public int getImageLength()
Returns the length of the encoded image.- Specified by:
getImageLength
in interfaceImageInfo
- Returns:
- the length of the encoded image
-
toString
public java.lang.String toString()
Returns a textual representation of this image info.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a textual representation of this image info
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
getEncoded
public byte[] getEncoded()
Encodes this image info.- Specified by:
getEncoded
in interfaceLDSElement
- Returns:
- a byte array containing the encoded image info
-
getImageInputStream
public java.io.InputStream getImageInputStream()
Returns the encoded image as an input stream.- Specified by:
getImageInputStream
in interfaceImageInfo
- Returns:
- an input stream containing the encoded image
-
readImage
protected void readImage(java.io.InputStream inputStream, long imageLength) throws java.io.IOException
Clients should call this method after positioning the input stream to the image bytes.- Parameters:
inputStream
- input streamimageLength
- image length- Throws:
java.io.IOException
- on error reading the input stream, for example at EOF
-
writeImage
protected void writeImage(java.io.OutputStream outputStream) throws java.io.IOException
Writes this image to a stream.- Parameters:
outputStream
- the stream to write to- Throws:
java.io.IOException
- on error writing to the stream
-
setMimeType
protected final void setMimeType(java.lang.String mimeType)
Sets the mime-type.- Parameters:
mimeType
- the new mime-type
-
setType
protected final void setType(int type)
Sets the type.- Parameters:
type
- the new type
-
setWidth
protected final void setWidth(int width)
Sets the width of this image.- Parameters:
width
- the new width
-
setHeight
protected final void setHeight(int height)
Sets the height of this image.- Parameters:
height
- the new height
-
setImageBytes
protected final void setImageBytes(byte[] imageBytes)
Sets the encoded image bytes of this image.- Parameters:
imageBytes
- the image bytes
-
readObject
protected abstract void readObject(java.io.InputStream inputStream) throws java.io.IOException
Reads this object from a stream.- Parameters:
inputStream
- the stream to read from- Throws:
java.io.IOException
- on error reading from the stream
-
writeObject
protected abstract void writeObject(java.io.OutputStream outputStream) throws java.io.IOException
Writes this object to a stream.- Parameters:
outputStream
- the stream to write to- Throws:
java.io.IOException
- on error writing to the stream
-
-