org.freehep.graphicsio
Class ImageGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.freehep.graphics2d.VectorGraphics
org.freehep.graphics2d.AbstractVectorGraphics
org.freehep.graphics2d.PixelGraphics2D
org.freehep.graphicsio.ImageGraphics2D
- All Implemented Interfaces:
- VectorGraphicsConstants
- Direct Known Subclasses:
- GIFGraphics2D
public class ImageGraphics2D
- extends PixelGraphics2D
Generic class for generating bitmap outputs from an image.
- Version:
- $Id: ImageGraphics2D.java 10273 2007-01-09 19:01:32Z duns $
- Author:
- Mark Donszelmann
Fields inherited from interface org.freehep.graphics2d.VectorGraphicsConstants |
NUMBER_OF_HORIZ_ALIGNMENTS, NUMBER_OF_SYMBOLS, NUMBER_OF_VERTICAL_ALIGNMENTS, SYMBOL_BOX, SYMBOL_CIRCLE, SYMBOL_CROSS, SYMBOL_DIAMOND, SYMBOL_DN_TRIANGLE, SYMBOL_HLINE, SYMBOL_PLUS, SYMBOL_STAR, SYMBOL_UP_TRIANGLE, SYMBOL_VLINE, TEXT_BASELINE, TEXT_BOTTOM, TEXT_CENTER, TEXT_LEFT, TEXT_RIGHT, TEXT_TOP |
Method Summary |
static boolean |
canWriteTransparent(String format)
|
static boolean |
canWriteUncompressed(String format)
|
void |
closeStream()
|
Graphics |
create()
|
Graphics |
create(double x,
double y,
double width,
double height)
|
static BufferedImage |
createBufferedImage(String format,
int width,
int height)
creates an empty image |
void |
endExport()
|
static BufferedImage |
generateThumbnail(Component component,
Dimension size)
|
static Properties |
getDefaultProperties(String format)
|
static SortedSet |
getImageWriters(Iterator iterator)
|
static ImageWriter |
getPreferredImageWriter(String format)
|
static ImageWriter |
getPreferredImageWriterForMIMEType(String mimeType)
|
static org.freehep.util.UserProperties |
getRAWProperties(Color bkg,
String code)
|
protected void |
handleException(Exception exception)
Handles an exception which has been caught. |
static BufferedImage |
readImage(String format,
InputStream is)
|
void |
setProperties(Properties newProperties)
|
void |
startExport()
|
static byte[] |
toByteArray(RenderedImage image,
String format,
String encoding,
Properties props)
Converts a given image to byte[] |
protected void |
write()
|
static void |
writeImage(Image image,
String format,
Properties properties,
OutputStream os)
|
static void |
writeImage(RenderedImage image,
String format,
Properties properties,
OutputStream os)
|
Methods inherited from class org.freehep.graphics2d.PixelGraphics2D |
addRenderingHints, clearRect, clearRect, clip, clipRect, clipRect, copyArea, createShape, dispose, draw, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, drawString, drawSymbol, fill, fillAndDrawSymbol, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillSymbol, getClip, getClipBounds, getClipBounds, getComposite, getDeviceConfiguration, getFontMetrics, getFontRenderContext, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, isDisplayLocal, isDisplayX11, printComment, rotate, rotate, scale, setBackground, setClip, setClip, setClip, setColor, setComposite, setFont, setHostGraphics, setLineWidth, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, setXORMode, shear, toString, transform, translate, translate |
Methods inherited from class org.freehep.graphics2d.AbstractVectorGraphics |
createShape, drawArc, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawRoundRect, drawString, drawString, drawString, drawString, drawString, drawSymbol, drawSymbol, fillAndDraw, fillAndDrawSymbol, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, fillRoundRect, fillSymbol, fillSymbol, getBackground, getColor, getColorMode, getCreator, getFont, getPaint, getPrintColor, getProperties, getProperty, getPropertyColor, getPropertyDimension, getPropertyDouble, getPropertyInsets, getPropertyInt, getPropertyRectangle, initProperties, isDeviceIndependent, isProperty, setColorMode, setCreator, setDeviceIndependent, setLineWidth |
rootKey
public static final String rootKey
- See Also:
- Constant Field Values
TRANSPARENT
public static final String TRANSPARENT
- See Also:
- Constant Field Values
BACKGROUND
public static final String BACKGROUND
- See Also:
- Constant Field Values
BACKGROUND_COLOR
public static final String BACKGROUND_COLOR
- See Also:
- Constant Field Values
ANTIALIAS
public static final String ANTIALIAS
- See Also:
- Constant Field Values
ANTIALIAS_TEXT
public static final String ANTIALIAS_TEXT
- See Also:
- Constant Field Values
PROGRESSIVE
public static final String PROGRESSIVE
- See Also:
- Constant Field Values
COMPRESS
public static final String COMPRESS
- See Also:
- Constant Field Values
COMPRESS_MODE
public static final String COMPRESS_MODE
- See Also:
- Constant Field Values
COMPRESS_DESCRIPTION
public static final String COMPRESS_DESCRIPTION
- See Also:
- Constant Field Values
COMPRESS_QUALITY
public static final String COMPRESS_QUALITY
- See Also:
- Constant Field Values
os
protected OutputStream os
image
protected BufferedImage image
format
protected String format
component
protected Component component
ImageGraphics2D
public ImageGraphics2D(File file,
Dimension size,
String format)
throws FileNotFoundException
- Throws:
FileNotFoundException
ImageGraphics2D
public ImageGraphics2D(File file,
Component component,
String format)
throws FileNotFoundException
- Throws:
FileNotFoundException
ImageGraphics2D
public ImageGraphics2D(OutputStream os,
Dimension size,
String format)
ImageGraphics2D
public ImageGraphics2D(OutputStream os,
Component component,
String format)
ImageGraphics2D
protected ImageGraphics2D(ImageGraphics2D graphics)
getDefaultProperties
public static Properties getDefaultProperties(String format)
setProperties
public void setProperties(Properties newProperties)
- Overrides:
setProperties
in class AbstractVectorGraphics
create
public Graphics create()
- Overrides:
create
in class PixelGraphics2D
create
public Graphics create(double x,
double y,
double width,
double height)
- Overrides:
create
in class PixelGraphics2D
startExport
public void startExport()
- Overrides:
startExport
in class PixelGraphics2D
endExport
public void endExport()
- Overrides:
endExport
in class PixelGraphics2D
write
protected void write()
throws IOException
- Throws:
IOException
closeStream
public void closeStream()
throws IOException
- Throws:
IOException
handleException
protected void handleException(Exception exception)
- Handles an exception which has been caught. Dispatches exception to
writeWarning for UnsupportedOperationExceptions and writeError for others
- Parameters:
exception
- to be handled
createBufferedImage
public static BufferedImage createBufferedImage(String format,
int width,
int height)
- creates an empty image
- Parameters:
format
- e.g. ImageConstants.BMP
or {ImageConstants#PNG}width
- image widthheight
- image height
- Returns:
- offscreen buffered image
generateThumbnail
public static BufferedImage generateThumbnail(Component component,
Dimension size)
writeImage
public static void writeImage(Image image,
String format,
Properties properties,
OutputStream os)
throws IOException
- Throws:
IOException
writeImage
public static void writeImage(RenderedImage image,
String format,
Properties properties,
OutputStream os)
throws IOException
- Throws:
IOException
getPreferredImageWriter
public static ImageWriter getPreferredImageWriter(String format)
getPreferredImageWriterForMIMEType
public static ImageWriter getPreferredImageWriterForMIMEType(String mimeType)
getImageWriters
public static SortedSet getImageWriters(Iterator iterator)
readImage
public static BufferedImage readImage(String format,
InputStream is)
throws IOException
- Throws:
IOException
canWriteUncompressed
public static boolean canWriteUncompressed(String format)
canWriteTransparent
public static boolean canWriteTransparent(String format)
getRAWProperties
public static org.freehep.util.UserProperties getRAWProperties(Color bkg,
String code)
- Parameters:
bkg
- Background color for the imagecode
- Color encoding, e.g. ImageConstants.COLOR_MODEL_RGB
- Returns:
- Properties used to create a RAW image
toByteArray
public static byte[] toByteArray(RenderedImage image,
String format,
String encoding,
Properties props)
throws IOException
- Converts a given image to byte[]
- Parameters:
image
- Image to convertformat
- e.g. ImageConstants.JPG
, ImageConstants#PNG, {@link ImageConstants#RAW}props
- Properties for writing, e.g. RawImageWriteParam.BACKGROUND
encoding
- ImageConstants.ENCODING_ASCII85
, ImageConstants.ENCODING_FLATE
or null
- Returns:
- bytes representing the image
- Throws:
IOException
- thrown by writeImage(java.awt.image.RenderedImage, String, java.util.Properties, java.io.OutputStream)
Copyright © 2012. All Rights Reserved.