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_GRAYFields inherited from class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedPropertyFields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanReset()Test if the methodOSGraphicsOps.reset()is supported.voidclose()Close resources.Get a graphics context for drawing.voidflush()Flush the output.voidFinal processing for writing an image file to the output stream.booleanDetermine if this instance is requesting an alpha channel.voidreset()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, toStringMethods inherited from class java.awt.Image
getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriorityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:OSGraphicsOpsGet a graphics context for drawing. The graphics context created is not valid afterOSGraphicsOps.flush()orOSGraphicsOps.reset()is called.- Specified by:
createGraphicsin interfaceGraphicsCreator- Specified by:
createGraphicsin interfaceOSGraphicsOps- Overrides:
createGraphicsin classBufferedImage- Returns:
- a new graphics context.
-
getGraphics
- Overrides:
getGraphicsin classBufferedImage
-
canReset
public boolean canReset()Description copied from interface:OSGraphicsOpsTest if the methodOSGraphicsOps.reset()is supported.- Specified by:
canResetin interfaceOSGraphicsOps- Returns:
- true if
OSGraphicsOps.reset()is supported; false otherwise
-
close
Description copied from interface:OSGraphicsOpsClose 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:
closein interfaceOSGraphicsOps- Throws:
IOException- if an IO error occurred
-
flush
public void flush()Description copied from interface:OSGraphicsOpsFlush 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:
flushin interfaceOSGraphicsOps- Overrides:
flushin classImage- See Also:
-
imageComplete
Description copied from interface:OSGraphicsOpsFinal 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:
imageCompletein 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:OSGraphicsOpsDetermine 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:
requestsAlphain interfaceOSGraphicsOps- Returns:
- true if an alpha channel is requested; false otherwise
-
reset
Description copied from interface:OSGraphicsOpsReset this graphics output stream. This is an optional operation as it is appropriate for some graphics output streams but not others- Specified by:
resetin interfaceOSGraphicsOps- Throws:
UnsupportedOperationException- an instance does not support resets
-