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, setRandomAccessFile
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
private 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()
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 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
private 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 streamOperationFailedException
public void process() throws OperationFailedException
Operation
process
in class Operation
WrongParameterException
- 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 operationOperationFailedException
private 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
IOException
private void saveHeader(PixelImage image) throws IOException, UnsupportedTypeException, WrongParameterException
private void savePalette(Palette palette) throws IOException
IOException
public 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 filenull
if no file extension can be recommended