java.lang.Object
java.awt.Image
java.awt.image.BufferedImage
org.bzdev.gio.OSGBufferedImage
- All Implemented Interfaces:
RenderedImage
,WritableRenderedImage
,Transparency
,GraphicsCreator
,OSGraphicsOps
Class to create a buffered image backed by an instance of
OutputStreamGraphics
. The method
imageComplete()
must be called when
an image is complete: otherwise the image file may not be
completely written or may not be written at all.-
Field Summary
Fields inherited from class java.awt.image.BufferedImage
TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, TYPE_BYTE_BINARY, TYPE_BYTE_GRAY, TYPE_BYTE_INDEXED, TYPE_CUSTOM, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_INT_RGB, TYPE_USHORT_555_RGB, TYPE_USHORT_565_RGB, TYPE_USHORT_GRAY
Fields inherited from class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canReset()
Test if the methodOSGraphicsOps.reset()
is supported.void
close()
Close resources.Get a graphics context for drawing.void
flush()
Flush the output.void
Final processing for writing an image file to the output stream.boolean
Determine if this instance is requesting an alpha channel.void
reset()
Reset this graphics output stream.Methods inherited from class java.awt.image.BufferedImage
addTileObserver, coerceData, copyData, getAlphaRaster, getColorModel, getData, getData, getHeight, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getProperty, getPropertyNames, getRaster, getRGB, getRGB, getSampleModel, getSource, getSources, getSubimage, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTransparency, getType, getWidth, getWidth, getWritableTile, getWritableTileIndices, hasTileWriters, isAlphaPremultiplied, isTileWritable, releaseWritableTile, removeTileObserver, setData, setRGB, setRGB, toString
Methods inherited from class java.awt.Image
getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bzdev.gio.OSGraphicsOps
getColorModel, getHeight, getWidth
-
Constructor Details
-
OSGBufferedImage
Constructor.- Parameters:
osg
- the output-stream graphics used to output images
-
-
Method Details
-
createGraphics
Description copied from interface:OSGraphicsOps
Get a graphics context for drawing. The graphics context created is not valid afterOSGraphicsOps.flush()
orOSGraphicsOps.reset()
is called.- Specified by:
createGraphics
in interfaceGraphicsCreator
- Specified by:
createGraphics
in interfaceOSGraphicsOps
- Overrides:
createGraphics
in classBufferedImage
- Returns:
- a new graphics context.
-
getGraphics
- Overrides:
getGraphics
in classBufferedImage
-
canReset
public boolean canReset()Description copied from interface:OSGraphicsOps
Test if the methodOSGraphicsOps.reset()
is supported.- Specified by:
canReset
in interfaceOSGraphicsOps
- Returns:
- true if
OSGraphicsOps.reset()
is supported; false otherwise
-
close
Description copied from interface:OSGraphicsOps
Close resources. Typically this method will perform some action when a class that implements this interface has an associated output stream or a resource that can be closed. If there are no such resources, this method should simply return. Classes that implement this method should document what they actually do.- Specified by:
close
in interfaceOSGraphicsOps
- Throws:
IOException
- if an IO error occurred
-
flush
public void flush()Description copied from interface:OSGraphicsOps
Flush the output. This method will provide a partial image or partial graphics if possible or feasible. After this method is called, the user must not use graphics contexts that were previously created. Whether this method performs any action depends on the implementation of each class or subclass implementing this interface.- Specified by:
flush
in interfaceOSGraphicsOps
- Overrides:
flush
in classImage
- See Also:
-
imageComplete
Description copied from interface:OSGraphicsOps
Final processing for writing an image file to the output stream. This method does not close an IO stream, but will flush it.Subclasses should implement this method so that it throws an exception if called multiple times without a successful intervening call to
OSGraphicsOps.reset()
. The methodOSGraphicsOps.canReset()
can be called to test if resets are allowed.- Specified by:
imageComplete
in interfaceOSGraphicsOps
- Throws:
IOException
- IO failure, or a PrintException (which will be provided as the cause of the IOException), or an indication that this method was called multiple times
-
requestsAlpha
public boolean requestsAlpha()Description copied from interface:OSGraphicsOps
Determine if this instance is requesting an alpha channel. The value may be changed from that provided in the constructor due to the capabilities of a particular image format.- Specified by:
requestsAlpha
in interfaceOSGraphicsOps
- Returns:
- true if an alpha channel is requested; false otherwise
-
reset
Description copied from interface:OSGraphicsOps
Reset this graphics output stream. This is an optional operation as it is appropriate for some graphics output streams but not others- Specified by:
reset
in interfaceOSGraphicsOps
- Throws:
UnsupportedOperationException
- an instance does not support resets
-