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 | Description |
|---|---|---|
private int |
bytesPerRow |
|
private static int |
COMPRESSION_NONE |
|
private int |
depth |
|
private int |
height |
|
private DataInput |
in |
|
private int |
length |
|
private int |
mapLength |
|
private int |
mapType |
|
private int |
numColors |
|
private 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 | Description |
|---|---|
RASCodec() |
| Modifier and Type | Method | Description |
|---|---|---|
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. |
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) |
|
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, setRandomAccessFileclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddProgressListener, 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 DataInput in
private DataOutput out
private Palette palette
public 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 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 IOException,
OperationFailedException
ImageCodec.setInputStream(InputStream).InvalidFileStructureException - if the input stream is corruptIOException - 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,
IOException
private IntegerImage readImage() throws InvalidFileStructureException, IOException
private Palette readPalette() throws InvalidFileStructureException, IOException
private void save()
throws IOException,
UnsupportedTypeException,
WrongParameterException
private void saveData(Paletted8Image image) throws IOException
IOExceptionprivate void saveHeader(PixelImage image) throws IOException, UnsupportedTypeException, WrongParameterException
private void savePalette(Palette palette) throws IOException
IOExceptionpublic 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