|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.ma2.image.ImageMediaHelper
public class ImageMediaHelper
Helper class for dealing with ImageIO-based images.
This class exists so the functionality can be shared between other MediaHandler implementations outside the .image package, which may need to render images from their media. Video handlers, for example, can use this class to render image previews for their video files.
Constructor Summary | |
---|---|
ImageMediaHelper()
|
Method Summary | |
---|---|
java.awt.image.BufferedImage |
getBufferedImage(java.awt.Image image)
Get a BufferedImage from an Image. |
javax.imageio.ImageReader |
getReaderForFile(java.io.File file)
Get an ImageReader for a File (based on file extension). |
javax.imageio.ImageReader |
getReaderForMIME(java.lang.String mime,
java.io.InputStream in)
Get an ImageReader for the given InputStream for the given MIME type. |
javax.imageio.ImageWriter |
getWriterForMIME(java.io.OutputStream out,
java.lang.String mime)
Get an ImageWriter for the given OutputStream for the given MIME type. |
javax.imageio.ImageWriter |
getWriterForMIME(java.lang.String mime)
Get an image writer for a specific MIME type. |
boolean |
hasAlpha(java.awt.Image image)
Returns true if the specified image has transparent pixels. |
void |
writeJpegStream(java.awt.image.BufferedImage image,
java.lang.Long itemId,
int quality,
java.io.OutputStream out)
Encode a JPEG image to an OutputStream with the specified quality. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImageMediaHelper()
Method Detail |
---|
public java.awt.image.BufferedImage getBufferedImage(java.awt.Image image)
image
- the image to get a BufferedImage for
public boolean hasAlpha(java.awt.Image image)
image
- the Image to test
public javax.imageio.ImageWriter getWriterForMIME(java.lang.String mime)
This method will be called by getWriterForMIME(OutputStream, String)
and will return an ImageWriter registered for item's MIME type, as
defined by MediaItem.getMime()
. Media handler implementations that wish
to generate an output type different than their native type can override this method.
mime
- the MIME type to get a ImageWriter for
public javax.imageio.ImageWriter getWriterForMIME(java.io.OutputStream out, java.lang.String mime)
This method will create an ImageOutputStream from the given OutputStream.
out
- the OutputStream to encode the image tomime
- the MIME type to get an ImageWriter for
public javax.imageio.ImageReader getReaderForFile(java.io.File file)
file
- the file to get the reader for
public javax.imageio.ImageReader getReaderForMIME(java.lang.String mime, java.io.InputStream in)
This method will create an ImageInputStream from the given InputStream.
mime
- the MIME to get an ImageReader forin
- the InputStream of the image to decode
public void writeJpegStream(java.awt.image.BufferedImage image, java.lang.Long itemId, int quality, java.io.OutputStream out)
image
- the image to encode as a JPEG streamitemId
- the media item ID being written (for logging only)quality
- integer between 0 and 100, with 100 being the higest qualityout
- the output stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |