public class RASCodec extends ImageCodec
.ras.
RASCodec codec = new RASCodec();
codec.setFile("image.ras", CodecMode.LOAD);
codec.process();
PixelImage loadedImage = codec.getImage();
Paletted8Image / uncompressed is supported when writing.
rasterfile(5) on Sun Unix systems.
That documentation can also be found online, e.g. at
http://www.doc.ic.ac.uk/~mac/manuals/sunos-manual-pages/sunos4/usr/man/man5/rasterfile.5.html.
A web search for rasterfile(5)
brings up other places as well.| Modifier and Type | Field and Description |
|---|---|
private int |
bytesPerRow |
private static int |
COMPRESSION_NONE |
private int |
depth |
private int |
height |
private java.io.DataInput |
in |
private int |
length |
private int |
mapLength |
private int |
mapType |
private int |
numColors |
private java.io.DataOutput |
out |
private int |
paddingBytes |
private Palette |
palette |
private static int |
RAS_HEADER_SIZE |
private static int |
RAS_MAGIC |
private int |
type |
private int |
width |
| Constructor and Description |
|---|
RASCodec() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getFormatName()
Returns the name of the file format supported by this codec.
|
java.lang.String[] |
getMimeTypes()
Return the MIME
(Multipurpose Internet Mail Extensions) type strings for this format, or
null
if none are available. |
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.
|
private void |
load()
Loads an image from an RAS input stream.
|
void |
process()
This method does the actual work of the operation.
|
private void |
readHeader() |
private IntegerImage |
readImage() |
private Palette |
readPalette() |
private void |
save() |
private void |
saveData(Paletted8Image image) |
private void |
saveHeader(PixelImage image) |
private void |
savePalette(Palette palette) |
java.lang.String |
suggestFileExtension(PixelImage image)
Attempts to suggest a filename extension.
|
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, setRandomAccessFileaddProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgressprivate static final int RAS_MAGIC
private static final int COMPRESSION_NONE
private static final int RAS_HEADER_SIZE
private int width
private int height
private int depth
private int length
private int type
private int mapType
private int mapLength
private int bytesPerRow
private int paddingBytes
private int numColors
private java.io.DataInput in
private java.io.DataOutput out
private Palette palette
public java.lang.String getFormatName()
ImageCodecImageCodec 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 ImageCodecpublic java.lang.String[] getMimeTypes()
ImageCodecnull
if none are available.getMimeTypes in class ImageCodecpublic boolean isLoadingSupported()
ImageCodectrue is returned this does not necessarily mean that all files in this
format can be read, but at least some.isLoadingSupported in class ImageCodecpublic boolean isSavingSupported()
ImageCodectrue is returned this does not necessarily mean that all types files in this
format can be written, but at least some.isSavingSupported in class ImageCodecprivate void load()
throws java.io.IOException,
OperationFailedException
ImageCodec.setInputStream(InputStream).InvalidFileStructureException - if the input stream is corruptjava.io.IOException - if there were problems reading from the input streamUnsupportedTypeException - if an unsupported flavor of the RAS format is encounteredWrongFileFormatException - if this is not a valid RAS streamOperationFailedExceptionpublic void process()
throws OperationFailedException
Operationprocess in class OperationWrongParameterException - if at least one of the input parameters was
not initialized appropriately (values out of the valid interval, etc.)MissingParameterException - if any mandatory parameter was not given to the operationOperationFailedExceptionprivate void readHeader()
throws InvalidFileStructureException,
UnsupportedTypeException,
WrongFileFormatException,
WrongParameterException,
java.io.IOException
InvalidFileStructureExceptionUnsupportedTypeExceptionWrongFileFormatExceptionWrongParameterExceptionjava.io.IOExceptionprivate IntegerImage readImage() throws InvalidFileStructureException, java.io.IOException
InvalidFileStructureExceptionjava.io.IOExceptionprivate Palette readPalette() throws InvalidFileStructureException, java.io.IOException
InvalidFileStructureExceptionjava.io.IOExceptionprivate void save()
throws java.io.IOException,
UnsupportedTypeException,
WrongParameterException
java.io.IOExceptionUnsupportedTypeExceptionWrongParameterExceptionprivate void saveData(Paletted8Image image) throws java.io.IOException
java.io.IOExceptionprivate void saveHeader(PixelImage image) throws java.io.IOException, UnsupportedTypeException, WrongParameterException
java.io.IOExceptionUnsupportedTypeExceptionWrongParameterExceptionprivate void savePalette(Palette palette) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String suggestFileExtension(PixelImage image)
ImageCodecPNMCodec).
This default implementation always returns null.suggestFileExtension in class ImageCodecimage - the image that is to be written to a filenull if no file extension can be recommended