Package net.sourceforge.jiu.codecs.jpeg
Class JPEGCodec
- java.lang.Object
-
- net.sourceforge.jiu.ops.Operation
-
- net.sourceforge.jiu.codecs.ImageCodec
-
- net.sourceforge.jiu.codecs.jpeg.JPEGCodec
-
public class JPEGCodec extends ImageCodec
A codec for the JPEG file format.Supported JPEG types
The codec is still under development. Nothing can be read with it right now. Writing JPEG files is not even in development stage.Credits
"JPEG Still Image Data Compression Standard" by William B. Pennebaker and Joan L. Mitchell. Published 1993 by Van Nostrand Reinhold. ISBN 0-442-01272-1. This book is referenced as P&M throughout the source code. It's an invaluable resource for anything related to JPEG.- Since:
- 0.13.0
- Author:
- Marco Schmidt
-
-
Constructor Summary
Constructors Constructor Description JPEGCodec()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
decodeScan(JPEGData jpegData)
String[]
getFileExtensions()
Returns all file extensions that are typical for this file format.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, ornull
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()
static void
main(String[] args)
void
process()
This method does the actual work of the operation.private void
readMarker(JPEGData jpegData, int marker, int length)
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, 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
-
-
-
-
Field Detail
-
in
private DataInput in
-
-
Method Detail
-
decodeScan
private void decodeScan(JPEGData jpegData)
-
getFileExtensions
public String[] getFileExtensions()
Description copied from class:ImageCodec
Returns all file extensions that are typical for this file format. The default implementation in ImageCodec returnsnull
. The file extension strings should include a leading dot and are supposed to be lower case (if that is allowed for the given file format). Example:{".jpg", ".jpeg"}
for the JPEG file format.- Overrides:
getFileExtensions
in classImageCodec
- Returns:
- String array with typical file extensions
-
getFormatName
public String getFormatName()
Description copied from class:ImageCodec
Returns the name of the file format supported by this codec. All classes extendingImageCodec
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
orPortable Anymap (PNM)
.- Specified by:
getFormatName
in classImageCodec
- 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, ornull
if none are available.- Specified by:
getMimeTypes
in classImageCodec
- 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. Iftrue
is returned this does not necessarily mean that all files in this format can be read, but at least some.- Specified by:
isLoadingSupported
in classImageCodec
- 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. Iftrue
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 classImageCodec
- Returns:
- if saving is supported
-
load
private void load() throws OperationFailedException, WrongFileFormatException
-
process
public void process() throws MissingParameterException, OperationFailedException, WrongFileFormatException
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 classOperation
- Throws:
MissingParameterException
- if any mandatory parameter was not given to the operationWrongParameterException
- if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)OperationFailedException
WrongFileFormatException
-
readMarker
private void readMarker(JPEGData jpegData, int marker, int length) throws InvalidFileStructureException, IOException, UnsupportedTypeException
-
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, seePNMCodec
). This default implementation always returnsnull
.- Overrides:
suggestFileExtension
in classImageCodec
- 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
-
-