JIU 0.14.3

net.sourceforge.jiu.codecs
Class RASCodec

java.lang.Object
  extended by net.sourceforge.jiu.ops.Operation
      extended by net.sourceforge.jiu.codecs.ImageCodec
          extended by net.sourceforge.jiu.codecs.RASCodec

public class RASCodec
extends ImageCodec

A codec to read and write Sun Raster (RAS) image files. The typical file extension for this format is .ras.

Usage example

This code snippet demonstrate how to read a RAS file.
 RASCodec codec = new RASCodec();
 codec.setFile("image.ras", CodecMode.LOAD);
 codec.process();
 PixelImage loadedImage = codec.getImage();
 

Supported file types when reading

Only uncompressed RAS files are read. Only 8 bit (gray and paletted) and 24 bit are supported when reading.

Supported image types when writing

Only Paletted8Image / uncompressed is supported when writing.

Bounds

The bounds concept of ImageCodec is supported so that you can load or save only part of an image.

File format documentation

This file format is documented as a man page 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.

Author:
Marco Schmidt

Constructor Summary
RASCodec()
           
 
Method Summary
 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.
 void process()
          This method does the actual work of the operation.
 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
 

Constructor Detail

RASCodec

public RASCodec()
Method Detail

getFormatName

public String getFormatName()
Description copied from class: ImageCodec
Returns the name of the file format supported by this codec. All classes extending 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).

Specified by:
getFormatName in class ImageCodec
Returns:
name of the file format supported by this codec

getMimeTypes

public String[] getMimeTypes()
Description copied from class: ImageCodec
Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or null if none are available.

Specified by:
getMimeTypes in class ImageCodec
Returns:
MIME type strings or null

isLoadingSupported

public boolean isLoadingSupported()
Description copied from class: ImageCodec
Returns if this codec is able to load images in the file format supported by this codec. If true is returned this does not necessarily mean that all files in this format can be read, but at least some.

Specified by:
isLoadingSupported in class ImageCodec
Returns:
if loading is supported

isSavingSupported

public boolean isSavingSupported()
Description copied from class: ImageCodec
Returns if this codec is able to save images in the file format supported by this codec. If true is returned this does not necessarily mean that all types files in this format can be written, but at least some.

Specified by:
isSavingSupported in class ImageCodec
Returns:
if saving is supported

process

public void process()
             throws OperationFailedException
Description copied from class: Operation
This method does the actual work of the operation. It must be called after all parameters have been given to the operation object.

Overrides:
process in class Operation
Throws:
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 operation
OperationFailedException

suggestFileExtension

public String suggestFileExtension(PixelImage image)
Description copied from class: ImageCodec
Attempts to suggest a filename extension. The type of the argument image will be taken into consideration, although this will be necessary for some file formats only (as an example, PNM has different extensions for different image types, see PNMCodec). This default implementation always returns null.

Overrides:
suggestFileExtension in class ImageCodec
Parameters:
image - the image that is to be written to a file
Returns:
the file extension, including a leading dot, or null if no file extension can be recommended

JIU 0.14.3

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Marco Schmidt