Java Doc for ImageCodec.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » com » sun » media » jai » codec » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » com.sun.media.jai.codec 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.media.jai.codec.ImageCodec

All known Subclasses:   com.sun.media.jai.codecimpl.TIFFCodec,  com.sun.media.jai.codecimpl.PNGCodec,  com.sun.media.jai.codecimpl.GIFCodec,  com.sun.media.jai.codecimpl.FPXCodec,  com.sun.media.jai.codecimpl.PNMCodec,  com.sun.media.jai.codecimpl.WBMPCodec,  com.sun.media.jai.codecimpl.JPEGCodec,  com.sun.media.jai.codecimpl.BMPCodec,
ImageCodec
abstract public class ImageCodec (Code)
An abstract class allowing the creation of image decoders and encoders. Instances of ImageCodec may be registered. Once a codec has been registered, the format name associated with it may be used as the name parameter in the createImageEncoder() and createImageDecoder() methods.

Additionally, subclasses of ImageCodec are able to perform recognition of their particular format, wither by inspection of a fixed-length file header or by arbitrary access to the source data stream.

Format recognition is performed by two variants of the isFormatRecognized() method. Which variant should be called is determined by the output of the codec's getNumHeaderBytes() method, which returns 0 if arbitrary access to the stream is required, and otherwise returns the number of header bytes required to recognize the format. Each subclass of ImageCodec needs to implement only one of the two variants.

This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.




Constructor Summary
protected  ImageCodec()
     Allow only subclasses to instantiate this class.

Method Summary
abstract public  booleancanEncodeImage(RenderedImage im, ImageEncodeParam param)
     Returns true if the given image and encoder param object are suitable for encoding by this ImageCodec.
public static  ColorModelcreateComponentColorModel(SampleModel sm)
     A convenience method to create an instance of ComponentColorModel suitable for use with the given SampleModel.
public static  ColorModelcreateComponentColorModel(SampleModel sm, ColorSpace cp)
     A convenience method to create an instance of ComponentColorModel suitable for use with the given SampleModel and .
public static  ColorModelcreateGrayIndexColorModel(SampleModel sm, boolean blackIsZero)
     A convenience methods to create an instance of IndexColorModel suitable for the given 1-banded SampleModel.
public static  ImageDecodercreateImageDecoder(String name, InputStream src, ImageDecodeParam param)
     Returns an ImageDecoder object suitable for decoding from the supplied InputStream, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - An InputStream to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null.
public static  ImageDecodercreateImageDecoder(String name, File src, ImageDecodeParam param)
     Returns an ImageDecoder object suitable for decoding from the supplied File, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - A File to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null.
public static  ImageDecodercreateImageDecoder(String name, SeekableStream src, ImageDecodeParam param)
     Returns an ImageDecoder object suitable for decoding from the supplied SeekableStream, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - A SeekableStream to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null.
protected  ImageDecodercreateImageDecoder(InputStream src, ImageDecodeParam param)
     Returns an implementation of the ImageDecoder interface appropriate for that codec.
protected  ImageDecodercreateImageDecoder(File src, ImageDecodeParam param)
     Returns an implementation of the ImageDecoder interface appropriate for that codec.
abstract protected  ImageDecodercreateImageDecoder(SeekableStream src, ImageDecodeParam param)
     In a concrete subclass of ImageCodec, returns an implementation of the ImageDecoder interface appropriate for that codec.
Parameters:
  dst - A SeekableStream to read from.
Parameters:
  param - An instance of ImageDecodeParamsuitable for use with the ImageCodecsubclass, or null.
public static  ImageEncodercreateImageEncoder(String name, OutputStream dst, ImageEncodeParam param)
     Returns an ImageEncoder object suitable for encoding to the supplied OutputStream, using the supplied ImageEncoderParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  dst - An OutputStream to write to.
Parameters:
  param - An instance of ImageEncoderParam suitablefor use with the named codec, or null.
abstract protected  ImageEncodercreateImageEncoder(OutputStream dst, ImageEncodeParam param)
     In a concrete subclass of ImageCodec, returns an implementation of the ImageEncoder interface appropriate for that codec.
Parameters:
  dst - An OutputStream to write to.
Parameters:
  param - An instance of ImageEncoderParamsuitable for use with the ImageCodecsubclass, or null.
public static  ImageCodecgetCodec(String name)
     Returns the ImageCodec associated with the given name.
public static  EnumerationgetCodecs()
     Returns an Enumeration of all regstered ImageCodec objects.
abstract protected  ClassgetDecodeParamClass()
     Returns a Class object indicating the proper subclass of ImageDecodeParam to be used with this ImageCodec.
public static  String[]getDecoderNames(SeekableStream src)
     Returns an array of Strings indicating the names of registered ImageCodecs that may be appropriate for reading the given SeekableStream.

If the src SeekableStream does not support seeking backwards (that is, its canSeekBackwards() method returns false) then only FormatRecognizers that require only a fixed-length header will be checked.

If the src stream does not support seeking backwards, it must support marking, as determined by its markSupported() method.
Parameters:
  src - A SeekableStream which optionally supportsseeking backwards.

abstract protected  ClassgetEncodeParamClass()
     Returns a Class object indicating the proper subclass of ImageEncodeParam to be used with this ImageCodec.
public static  String[]getEncoderNames(RenderedImage im, ImageEncodeParam param)
     Returns an array of Strings indicating the names of registered ImageCodecs that may be appropriate for writing the given RenderedImage, using the optional ImageEncodeParam, which may be null.
Parameters:
  im - A RenderedImage to be encodec.
Parameters:
  param - An ImageEncodeParam, or null.
abstract public  StringgetFormatName()
     Returns the name of this image format.
public  intgetNumHeaderBytes()
     Returns the number of bytes of header needed to recognize the format, or 0 if an arbitrary number of bytes may be needed.
public  booleanisFormatRecognized(byte[] header)
     Returns true if the format is recognized in the initial portion of a stream.
public  booleanisFormatRecognized(SeekableStream src)
     Returns true if the format is recognized in the input data stream.
public static  booleanisIndicesForGrayscale(byte[] r, byte[] g, byte[] b)
     Tests whether the color indices represent a gray-scale image.
Parameters:
  r - The red channel color indices.
Parameters:
  g - The green channel color indices.
Parameters:
  b - The blue channel color indices.
public static  voidregisterCodec(ImageCodec codec)
     Associates an ImageCodec with its format name, as determined by its getFormatName() method.
public static  voidunregisterCodec(String name)
     Unregisters the ImageCodec object currently responsible for handling the named format.


Constructor Detail
ImageCodec
protected ImageCodec()(Code)
Allow only subclasses to instantiate this class.




Method Detail
canEncodeImage
abstract public boolean canEncodeImage(RenderedImage im, ImageEncodeParam param)(Code)
Returns true if the given image and encoder param object are suitable for encoding by this ImageCodec. For example, some codecs may only deal with images with a certain number of bands; an attempt to encode an image with an unsupported number of bands will fail.
Parameters:
  im - a RenderedImage whose ability to be encoded is to bedetermined.
Parameters:
  param - a suitable ImageEncodeParam object,or null.



createComponentColorModel
public static ColorModel createComponentColorModel(SampleModel sm)(Code)
A convenience method to create an instance of ComponentColorModel suitable for use with the given SampleModel. The SampleModel should have a data type of DataBuffer.TYPE_BYTE, TYPE_USHORT, or TYPE_INT and between 1 and 4 bands. Depending on the number of bands of the SampleModel, either a gray, gray+alpha, rgb, or rgb+alpha ColorModel is returned.



createComponentColorModel
public static ColorModel createComponentColorModel(SampleModel sm, ColorSpace cp)(Code)
A convenience method to create an instance of ComponentColorModel suitable for use with the given SampleModel and . The SampleModel should have a data type of DataBuffer.TYPE_BYTE, TYPE_USHORT, or TYPE_INT and between 1 and 4 bands. Depending on the number of bands of the SampleModel, either a gray, gray+alpha, rgb, or rgb+alpha ColorModel is returned.



createGrayIndexColorModel
public static ColorModel createGrayIndexColorModel(SampleModel sm, boolean blackIsZero)(Code)
A convenience methods to create an instance of IndexColorModel suitable for the given 1-banded SampleModel.
Parameters:
  sm - a 1-banded SampleModel.
Parameters:
  blackIsZero - true if the gray ramp shouldgo from black to white, falseotherwise.



createImageDecoder
public static ImageDecoder createImageDecoder(String name, InputStream src, ImageDecodeParam param)(Code)
Returns an ImageDecoder object suitable for decoding from the supplied InputStream, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - An InputStream to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null. An instance of ImageDecoder, or null.



createImageDecoder
public static ImageDecoder createImageDecoder(String name, File src, ImageDecodeParam param) throws IOException(Code)
Returns an ImageDecoder object suitable for decoding from the supplied File, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - A File to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null. An instance of ImageDecoder, or null.



createImageDecoder
public static ImageDecoder createImageDecoder(String name, SeekableStream src, ImageDecodeParam param)(Code)
Returns an ImageDecoder object suitable for decoding from the supplied SeekableStream, using the supplied ImageDecodeParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  src - A SeekableStream to read from.
Parameters:
  param - An instance of ImageDecodeParam suitablefor use with the named codec, or null. An instance of ImageDecoder, or null.



createImageDecoder
protected ImageDecoder createImageDecoder(InputStream src, ImageDecodeParam param)(Code)
Returns an implementation of the ImageDecoder interface appropriate for that codec. Subclasses of ImageCodec may override this method if they wish to accept data directly from an InputStream; otherwise, this method will convert the source into a backwards-seekable SeekableStream and call the appropriate version of createImageDecoder for that data type.

Instances of ImageCodec that do not require the ability to seek backwards in their source SeekableStream should override this method in order to avoid the default call to SeekableStream.wrapInputStream(src, true).
Parameters:
  dst - An InputStream to read from.
Parameters:
  param - An instance of ImageDecodeParamsuitable for use with the ImageCodecsubclass, or null. An instance of ImageDecoder.




createImageDecoder
protected ImageDecoder createImageDecoder(File src, ImageDecodeParam param) throws IOException(Code)
Returns an implementation of the ImageDecoder interface appropriate for that codec. Subclasses of ImageCodec may override this method if they wish to accept data directly from a File; otherwise, this method will convert the source into a SeekableStream and call the appropriate version of createImageDecoder for that data type.
Parameters:
  dst - A File to read from.
Parameters:
  param - An instance of ImageDecodeParamsuitable for use with the ImageCodecsubclass, or null. An instance of ImageDecoder.



createImageDecoder
abstract protected ImageDecoder createImageDecoder(SeekableStream src, ImageDecodeParam param)(Code)
In a concrete subclass of ImageCodec, returns an implementation of the ImageDecoder interface appropriate for that codec.
Parameters:
  dst - A SeekableStream to read from.
Parameters:
  param - An instance of ImageDecodeParamsuitable for use with the ImageCodecsubclass, or null. An instance of ImageDecoder.



createImageEncoder
public static ImageEncoder createImageEncoder(String name, OutputStream dst, ImageEncodeParam param)(Code)
Returns an ImageEncoder object suitable for encoding to the supplied OutputStream, using the supplied ImageEncoderParam object.
Parameters:
  name - The name associated with the codec.
Parameters:
  dst - An OutputStream to write to.
Parameters:
  param - An instance of ImageEncoderParam suitablefor use with the named codec, or null. An instance of ImageEncoder, or null.



createImageEncoder
abstract protected ImageEncoder createImageEncoder(OutputStream dst, ImageEncodeParam param)(Code)
In a concrete subclass of ImageCodec, returns an implementation of the ImageEncoder interface appropriate for that codec.
Parameters:
  dst - An OutputStream to write to.
Parameters:
  param - An instance of ImageEncoderParamsuitable for use with the ImageCodecsubclass, or null. An instance of ImageEncoder.



getCodec
public static ImageCodec getCodec(String name)(Code)
Returns the ImageCodec associated with the given name. null is returned if no codec is registered with the given name. Case is not significant.
Parameters:
  name - The name associated with the codec. The associated ImageCodec, or null.



getCodecs
public static Enumeration getCodecs()(Code)
Returns an Enumeration of all regstered ImageCodec objects.



getDecodeParamClass
abstract protected Class getDecodeParamClass()(Code)
Returns a Class object indicating the proper subclass of ImageDecodeParam to be used with this ImageCodec. If encoding is not supported by this codec, null is returned. If decoding is supported, but a parameter object is not used during decoding, Object.class is returned to signal this fact.



getDecoderNames
public static String[] getDecoderNames(SeekableStream src)(Code)
Returns an array of Strings indicating the names of registered ImageCodecs that may be appropriate for reading the given SeekableStream.

If the src SeekableStream does not support seeking backwards (that is, its canSeekBackwards() method returns false) then only FormatRecognizers that require only a fixed-length header will be checked.

If the src stream does not support seeking backwards, it must support marking, as determined by its markSupported() method.
Parameters:
  src - A SeekableStream which optionally supportsseeking backwards. An array of Strings.
throws:
  IllegalArgumentException - if src supportsneither seeking backwards nor marking.




getEncodeParamClass
abstract protected Class getEncodeParamClass()(Code)
Returns a Class object indicating the proper subclass of ImageEncodeParam to be used with this ImageCodec. If encoding is not supported by this codec, null is returned. If encoding is supported, but a parameter object is not used during encoding, Object.class is returned to signal this fact.



getEncoderNames
public static String[] getEncoderNames(RenderedImage im, ImageEncodeParam param)(Code)
Returns an array of Strings indicating the names of registered ImageCodecs that may be appropriate for writing the given RenderedImage, using the optional ImageEncodeParam, which may be null.
Parameters:
  im - A RenderedImage to be encodec.
Parameters:
  param - An ImageEncodeParam, or null. An array of Strings.



getFormatName
abstract public String getFormatName()(Code)
Returns the name of this image format. A String containing the name of theimage format supported by this codec.



getNumHeaderBytes
public int getNumHeaderBytes()(Code)
Returns the number of bytes of header needed to recognize the format, or 0 if an arbitrary number of bytes may be needed. The default implementation returns 0.

The return value must be a constant for all instances of each particular subclass of ImageCodec.

Although it is legal to always return 0, in some cases processing may be more efficient if the number of bytes needed is known in advance.




isFormatRecognized
public boolean isFormatRecognized(byte[] header)(Code)
Returns true if the format is recognized in the initial portion of a stream. The header will be passed in as a byte array of length getNumHeaderBytes(). This method should be called only if getNumHeaderBytes() returns a value greater than 0.

The default implementation throws an exception to indicate that it should never be called.
Parameters:
  header - An array of bytes containing the inputstream header. true if the format is recognized.




isFormatRecognized
public boolean isFormatRecognized(SeekableStream src) throws IOException(Code)
Returns true if the format is recognized in the input data stream. This method should be called only if getNumHeaderBytesNeeded() returns 0.

The source SeekableStream is guaranteed to support seeking backwards, and should be seeked to 0 prior to calling this method.

The default implementation throws an exception to indicate that it should never be called.
Parameters:
  src - A SeekableStream containing the inputdata. true if the format is recognized.




isIndicesForGrayscale
public static boolean isIndicesForGrayscale(byte[] r, byte[] g, byte[] b)(Code)
Tests whether the color indices represent a gray-scale image.
Parameters:
  r - The red channel color indices.
Parameters:
  g - The green channel color indices.
Parameters:
  b - The blue channel color indices. If all the indices have 256 entries, and are identical mappings,return true; otherwise, return false.



registerCodec
public static void registerCodec(ImageCodec codec)(Code)
Associates an ImageCodec with its format name, as determined by its getFormatName() method. Case is not significant. Any codec previously associated with the name is discarded.
Parameters:
  codec - The ImageCodec object to be registered.



unregisterCodec
public static void unregisterCodec(String name)(Code)
Unregisters the ImageCodec object currently responsible for handling the named format. Case is not significant.
Parameters:
  name - The name associated with the codec to be removed.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.