public class GIFImageWriter extends ImageWriter
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG |
(package private) static String |
IMAGE_METADATA_NAME |
private int |
imageIndex
The index of the image being written.
|
private boolean |
isWritingSequence
Whether a sequence is being written.
|
(package private) static String |
STANDARD_METADATA_NAME |
private ImageOutputStream |
stream
The
output case to an ImageOutputStream . |
(package private) static String |
STREAM_METADATA_NAME |
private GIFWritableStreamMetadata |
theStreamMetadata
The stream metadata of a sequence.
|
private boolean |
wroteSequenceHeader
Whether the header has been written.
|
availableLocales, locale, originatingProvider, output, progressListeners, warningListeners, warningLocales
Constructor and Description |
---|
GIFImageWriter(GIFImageWriterSpi originatingProvider) |
Modifier and Type | Method and Description |
---|---|
boolean |
canWriteSequence() |
private static void |
computeRegions(Rectangle sourceBounds,
Dimension destSize,
ImageWriteParam p)
Compute the source region and destination dimensions taking any
parameter settings into account.
|
IIOMetadata |
convertImageMetadata(IIOMetadata inData,
ImageTypeSpecifier imageType,
ImageWriteParam param)
Creates a default image metadata object and merges in the
supplied metadata.
|
private void |
convertMetadata(String metadataFormatName,
IIOMetadata inData,
IIOMetadata outData)
Merges
inData into outData . |
IIOMetadata |
convertStreamMetadata(IIOMetadata inData,
ImageWriteParam param)
Creates a default stream metadata object and merges in the
supplied metadata.
|
private static byte[] |
createColorTable(ColorModel colorModel,
SampleModel sampleModel)
Create a color table from the image ColorModel and SampleModel.
|
void |
endWriteSequence() |
IIOMetadata |
getDefaultImageMetadata(ImageTypeSpecifier imageType,
ImageWriteParam param) |
IIOMetadata |
getDefaultStreamMetadata(ImageWriteParam param) |
ImageWriteParam |
getDefaultWriteParam() |
private static int |
getGifPaletteSize(int x)
According do GIF specification size of clor table (palette here)
must be in range from 2 to 256 and must be power of 2.
|
private static int |
getNumBits(int value)
The number of bits represented by the value which should be a
legal length for a color table.
|
private boolean |
needToCreateIndex(RenderedImage image) |
void |
prepareWriteSequence(IIOMetadata streamMetadata) |
void |
reset() |
private void |
resetLocal()
Resets locally defined instance variables.
|
void |
setOutput(Object output) |
private void |
write(boolean writeHeader,
boolean writeTrailer,
IIOMetadata sm,
IIOImage iioimage,
ImageWriteParam p)
Writes any extension blocks, the Image Descriptor, the image data,
and optionally the header (Signature and Logical Screen Descriptor)
and trailer (Block Terminator).
|
void |
write(IIOMetadata sm,
IIOImage iioimage,
ImageWriteParam p) |
private void |
writeApplicationExtension(GIFWritableImageMetadata im) |
private void |
writeBlocks(byte[] data) |
private void |
writeCommentExtension(GIFWritableImageMetadata im) |
private void |
writeGraphicControlExtension(GIFWritableImageMetadata im) |
private void |
writeGraphicControlExtension(int disposalMethod,
boolean userInputFlag,
boolean transparentColorFlag,
int delayTime,
int transparentColorIndex) |
private void |
writeHeader(IIOMetadata streamMetadata,
int bitsPerPixel) |
private void |
writeHeader(String version,
int logicalScreenWidth,
int logicalScreenHeight,
int colorResolution,
int pixelAspectRatio,
int backgroundColorIndex,
boolean sortFlag,
int bitsPerPixel,
byte[] globalColorTable) |
private void |
writeImage(RenderedImage image,
GIFWritableImageMetadata imageMetadata,
ImageWriteParam param,
byte[] globalColorTable,
Rectangle sourceBounds,
Dimension destSize)
Writes any extension blocks, the Image Descriptor, and the image data
|
private void |
writeImageDescriptor(GIFWritableImageMetadata imageMetadata,
int bitsPerPixel) |
private void |
writeImageDescriptor(int imageLeftPosition,
int imageTopPosition,
int imageWidth,
int imageHeight,
boolean interlaceFlag,
boolean sortFlag,
int bitsPerPixel,
byte[] localColorTable) |
private void |
writePlainTextExtension(GIFWritableImageMetadata im) |
private void |
writeRasterData(RenderedImage image,
Rectangle sourceBounds,
Dimension destSize,
ImageWriteParam param,
boolean interlaceFlag) |
private void |
writeRows(RenderedImage image,
LZWCompressor compressor,
int sx,
int sdx,
int sy,
int sdy,
int sw,
int dy,
int ddy,
int dw,
int dh,
int numRowsWritten,
int progressReportRowPeriod) |
private void |
writeRowsOpt(byte[] data,
int offset,
int lineStride,
LZWCompressor compressor,
int dy,
int ddy,
int dw,
int dh,
int numRowsWritten,
int progressReportRowPeriod) |
void |
writeToSequence(IIOImage image,
ImageWriteParam param) |
private void |
writeTrailer() |
abort, abortRequested, addIIOWriteProgressListener, addIIOWriteWarningListener, canInsertEmpty, canInsertImage, canRemoveImage, canReplaceImageMetadata, canReplacePixels, canReplaceStreamMetadata, canWriteEmpty, canWriteRasters, clearAbortRequest, dispose, endInsertEmpty, endReplacePixels, endWriteEmpty, getAvailableLocales, getLocale, getNumThumbnailsSupported, getOriginatingProvider, getOutput, getPreferredThumbnailSizes, prepareInsertEmpty, prepareReplacePixels, prepareWriteEmpty, processImageComplete, processImageProgress, processImageStarted, processThumbnailComplete, processThumbnailProgress, processThumbnailStarted, processWarningOccurred, processWarningOccurred, processWriteAborted, removeAllIIOWriteProgressListeners, removeAllIIOWriteWarningListeners, removeIIOWriteProgressListener, removeIIOWriteWarningListener, removeImage, replaceImageMetadata, replacePixels, replacePixels, replaceStreamMetadata, setLocale, write, write, writeInsert
private static final boolean DEBUG
static final String STANDARD_METADATA_NAME
static final String STREAM_METADATA_NAME
static final String IMAGE_METADATA_NAME
private ImageOutputStream stream
output
case to an ImageOutputStream
.private boolean isWritingSequence
private boolean wroteSequenceHeader
private GIFWritableStreamMetadata theStreamMetadata
private int imageIndex
public GIFImageWriter(GIFImageWriterSpi originatingProvider)
private static int getNumBits(int value) throws IOException
IOException
private static void computeRegions(Rectangle sourceBounds, Dimension destSize, ImageWriteParam p)
private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel)
private static int getGifPaletteSize(int x)
public boolean canWriteSequence()
canWriteSequence
in class ImageWriter
private void convertMetadata(String metadataFormatName, IIOMetadata inData, IIOMetadata outData)
inData
into outData
. The supplied
metadata format name is attempted first and failing that the standard
metadata format name is attempted.public IIOMetadata convertStreamMetadata(IIOMetadata inData, ImageWriteParam param)
convertStreamMetadata
in interface ImageTranscoder
convertStreamMetadata
in class ImageWriter
public IIOMetadata convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param)
convertImageMetadata
in interface ImageTranscoder
convertImageMetadata
in class ImageWriter
public void endWriteSequence() throws IOException
endWriteSequence
in class ImageWriter
IOException
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param)
getDefaultImageMetadata
in class ImageWriter
public IIOMetadata getDefaultStreamMetadata(ImageWriteParam param)
getDefaultStreamMetadata
in class ImageWriter
public ImageWriteParam getDefaultWriteParam()
getDefaultWriteParam
in class ImageWriter
public void prepareWriteSequence(IIOMetadata streamMetadata) throws IOException
prepareWriteSequence
in class ImageWriter
IOException
public void reset()
reset
in class ImageWriter
private void resetLocal()
public void setOutput(Object output)
setOutput
in class ImageWriter
public void write(IIOMetadata sm, IIOImage iioimage, ImageWriteParam p) throws IOException
write
in class ImageWriter
IOException
public void writeToSequence(IIOImage image, ImageWriteParam param) throws IOException
writeToSequence
in class ImageWriter
IOException
private boolean needToCreateIndex(RenderedImage image)
private void write(boolean writeHeader, boolean writeTrailer, IIOMetadata sm, IIOImage iioimage, ImageWriteParam p) throws IOException
writeHeader
- Whether to write the header.writeTrailer
- Whether to write the trailer.sm
- The stream metadata or null
if
writeHeader
is false
.iioimage
- The image and image metadata.p
- The write parameters.IllegalArgumentException
- if the number of bands is not 1.IllegalArgumentException
- if the number of bits per sample is
greater than 8.IllegalArgumentException
- if the color component size is
greater than 8.IllegalArgumentException
- if writeHeader
is
true
and sm
is null
.IllegalArgumentException
- if writeHeader
is
false
and a sequence is not being written.IOException
private void writeImage(RenderedImage image, GIFWritableImageMetadata imageMetadata, ImageWriteParam param, byte[] globalColorTable, Rectangle sourceBounds, Dimension destSize) throws IOException
image
- The image and image metadata.param
- The write parameters.globalColorTable
- The Global Color Table.sourceBounds
- The source region.destSize
- The destination dimensions.IOException
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException
IOException
private void writeRowsOpt(byte[] data, int offset, int lineStride, LZWCompressor compressor, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException
IOException
private void writeRasterData(RenderedImage image, Rectangle sourceBounds, Dimension destSize, ImageWriteParam param, boolean interlaceFlag) throws IOException
IOException
private void writeHeader(String version, int logicalScreenWidth, int logicalScreenHeight, int colorResolution, int pixelAspectRatio, int backgroundColorIndex, boolean sortFlag, int bitsPerPixel, byte[] globalColorTable) throws IOException
IOException
private void writeHeader(IIOMetadata streamMetadata, int bitsPerPixel) throws IOException
IOException
private void writeGraphicControlExtension(int disposalMethod, boolean userInputFlag, boolean transparentColorFlag, int delayTime, int transparentColorIndex) throws IOException
IOException
private void writeGraphicControlExtension(GIFWritableImageMetadata im) throws IOException
IOException
private void writeBlocks(byte[] data) throws IOException
IOException
private void writePlainTextExtension(GIFWritableImageMetadata im) throws IOException
IOException
private void writeApplicationExtension(GIFWritableImageMetadata im) throws IOException
IOException
private void writeCommentExtension(GIFWritableImageMetadata im) throws IOException
IOException
private void writeImageDescriptor(int imageLeftPosition, int imageTopPosition, int imageWidth, int imageHeight, boolean interlaceFlag, boolean sortFlag, int bitsPerPixel, byte[] localColorTable) throws IOException
IOException
private void writeImageDescriptor(GIFWritableImageMetadata imageMetadata, int bitsPerPixel) throws IOException
IOException
private void writeTrailer() throws IOException
IOException
Copyright © 2017 Open Microscopy Environment