|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.codecs.ImageCodec
net.sourceforge.jiu.codecs.PNMCodec
A codec to read and write Portable Anymap (PNM) image files. This format includes three file types well-known in the Unix world:
The header of a PGM and PPM file stores a maximum sample value (such a value is not stored for PBM, where the maximum value is always 1). When in binary mode, PGM and PPM typically have a maximum sample value of 255, which makes PGM 8 bits per pixel and PPM 24 bits per pixel large. One sample will be stored as a single byte. However, there also exist binary PGM files with a maximum sample value larger than 255 and smaller than 65536. These files use two bytes per sample, in network byte order (big endian). I have yet to see PPM files with that property, but they are of course imagineable. 16 bpp
PNMCodec codec = new PNMCodec(); codec.setFile("test.ppm", CodecMode.LOAD); codec.process(); codec.close(); PixelImage image = codec.getImage();
PNMCodec codec = new PNMCodec(); BilevelImage myFax = ...; // initialize codec.setImage(myFax); codec.setFile("out.pbm", CodecMode.SAVE); codec.process(); codec.close();
Field Summary | |
static int |
IMAGE_TYPE_BILEVEL
Image type constant for bilevel images, stored in PBM files. |
static int |
IMAGE_TYPE_COLOR
Image type constant for RGB truecolor images, stored in PPM files. |
static int |
IMAGE_TYPE_GRAY
Image type constant for grayscale images, stored in PGM files. |
static int |
IMAGE_TYPE_UNKNOWN
Image type constant for images of unknown type. |
Constructor Summary | |
PNMCodec()
|
Method Summary | |
static int |
determineImageTypeFromFileName(String fileName)
Attempts to find the appropriate image type by looking at a file's name. |
Boolean |
getAscii()
Returns if ASCII mode was used for loading an image or will be used to store an image. |
String |
getFormatName()
Returns the name of the file format supported by this codec. |
String[] |
getMimeTypes()
Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or null
if none are available. |
static String |
getTypicalFileExtension(int imageType)
Returns the typical file extension (including leading dot) for an image type. |
boolean |
isLoadingSupported()
Returns if this codec is able to load images in the file format supported by this codec. |
boolean |
isSavingSupported()
Returns if this codec is able to save images in the file format supported by this codec. |
void |
process()
This method does the actual work of the operation. |
void |
setAscii(boolean asciiMode)
Specify whether ASCII mode is to be used when saving an image. |
String |
suggestFileExtension(PixelImage image)
Attempts to suggest a filename extension. |
Methods inherited from class net.sourceforge.jiu.codecs.ImageCodec |
appendComment, checkBounds, checkImageResolution, close, getBoundsHeight, getBoundsWidth, getBoundsX1, getBoundsX2, getBoundsY1, getBoundsY2, getComment, getDataInput, getDataOutput, getDpiX, getDpiY, getFileExtensions, getImage, getImageIndex, getInputAsDataInput, getInputStream, getMode, getNumComments, getOutputAsDataOutput, getOutputStream, getRandomAccessFile, hasBounds, initModeFromIOObjects, isRowRequired, isTileRequired, removeAllComments, removeBounds, setBounds, setBoundsIfNecessary, setDataInput, setDataOutput, setDpi, setFile, setFile, setImage, setImageIndex, setInputStream, setOutputStream, setRandomAccessFile |
Methods inherited from class net.sourceforge.jiu.ops.Operation |
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int IMAGE_TYPE_UNKNOWN
public static final int IMAGE_TYPE_BILEVEL
public static final int IMAGE_TYPE_GRAY
public static final int IMAGE_TYPE_COLOR
Constructor Detail |
public PNMCodec()
Method Detail |
public static int determineImageTypeFromFileName(String fileName)
IMAGE_TYPE_BILEVEL
for .pbm
,
IMAGE_TYPE_GRAY
for .pgm
and
IMAGE_TYPE_COLOR
for .ppm
.
Otherwise, IMAGE_TYPE_UNKNOWN
is returned.
To get a file extension given that you have an image type, use
getTypicalFileExtension(int)
.
fileName
- the file name to be examined
IMAGE_TYPE_xxx
constants of this classpublic Boolean getAscii()
setAscii(boolean)
public String getFormatName()
ImageCodec
ImageCodec
must override this method.
When overriding, leave out any words in a particular language so
that this format name can be understood by everyone.
Usually it is enough to return the format creator plus a typical
abbreviation, e.g. Microsoft BMP
or Portable Anymap (PNM)
.
getFormatName
in class ImageCodec
public String[] getMimeTypes()
ImageCodec
null
if none are available.
getMimeTypes
in class ImageCodec
public static String getTypicalFileExtension(int imageType)
null
for IMAGE_TYPE_UNKNOWN
.
To get the image type given that you have a file name, use
determineImageTypeFromFileName(java.lang.String)
.
imageType
- the image type for which the extension is required
public boolean isLoadingSupported()
ImageCodec
true
is returned this does not necessarily mean that all files in this
format can be read, but at least some.
isLoadingSupported
in class ImageCodec
public boolean isSavingSupported()
ImageCodec
true
is returned this does not necessarily mean that all types files in this
format can be written, but at least some.
isSavingSupported
in class ImageCodec
public void process() throws MissingParameterException, OperationFailedException
Operation
process
in class Operation
MissingParameterException
- if any mandatory parameter was not given to the operation
OperationFailedException
public void setAscii(boolean asciiMode)
asciiMode
- if true, ASCII mode is used, binary mode otherwisepublic String suggestFileExtension(PixelImage image)
ImageCodec
PNMCodec
).
This default implementation always returns null
.
suggestFileExtension
in class ImageCodec
image
- the image that is to be written to a file
null
if no file extension can be recommended
|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |