public class ImageDecoder extends Object
Modifier and Type | Field and Description |
---|---|
protected static int[] |
signature |
protected int |
transparentColor |
protected int |
transparentColorLow |
Constructor and Description |
---|
ImageDecoder() |
ImageDecoder(FormattedDataSource source,
ImageMaker maker) |
Modifier and Type | Method and Description |
---|---|
boolean |
analyze(FormattedDataSource source) |
void |
analyze(FormattedDataSource source,
Dimension size)
Analyze the image represented by source and set the width and
height of the image.
|
boolean |
analyze(FormattedDataSource source,
ImageInfo destInfo) |
void |
decode(FormattedDataSource source,
ImageMaker maker) |
void |
decode(FormattedDataSource source,
ImageMaker maker,
Rect srcArea,
Dimension newSize,
int createOptions)
Decode a portion of the Image to the ImageMaker.
|
Picture |
decodeFully()
Only call this after calling analyze() and then optionally calling
setSourceAndDestination().
|
void |
decodeFully(ImageMaker dest) |
static IImage |
decodeScaled(FormattedDataSource fds,
int newWidth,
int newHeight,
boolean shouldScale,
int scaleOptions,
Dimension fullSize,
ImageMaker destination)
Decode a possibly scaled image.
|
static Picture |
decodeScaledPicture(FormattedDataSource fds,
Dimension newSize,
boolean keepAspectRatio,
boolean scaleDownOnly,
Dimension fullSize)
Decode a possibly scaled picture.
|
static Picture |
decodeScaledPicture(FormattedDataSource fds,
int newWidth,
int newHeight,
boolean shouldScale,
boolean keepAspectRatio,
boolean scaleDownOnly,
Dimension fullSize)
Decode a possibly scaled picture.
|
void |
free() |
protected eve.fx.pngChunk |
getChunk(RandomStream ras) |
ImageDataInfo |
getImageDataInfo(ImageDataInfo destInfo) |
static boolean |
hasBMPSignature(byte[] startData) |
static boolean |
hasGIFSignature(byte[] startData) |
static boolean |
hasJPEGSignature(byte[] startData) |
static boolean |
hasPNGSignature(byte[] startData) |
static boolean |
isDecodable(byte[] first16Bytes) |
void |
setSourceAndDestination(Rect srcArea,
Dimension newSize,
int createOptions,
Dimension trueNewSize)
Call this after analyze() to
setup the requested source area to decode and final size of the
decoded image.
|
String |
toString()
Return a String representation of this object.
|
protected static final int[] signature
protected int transparentColor
protected int transparentColorLow
public ImageDecoder()
public ImageDecoder(FormattedDataSource source, ImageMaker maker) throws ImageDecodingException
ImageDecodingException
protected eve.fx.pngChunk getChunk(RandomStream ras) throws IOException
IOException
public static boolean hasPNGSignature(byte[] startData)
public static boolean hasBMPSignature(byte[] startData)
public static boolean hasGIFSignature(byte[] startData)
public static boolean hasJPEGSignature(byte[] startData)
public static boolean isDecodable(byte[] first16Bytes)
public void free()
public boolean analyze(FormattedDataSource source) throws IOException, ImageDecodingException
source
- IOException
ImageDecodingException
public void analyze(FormattedDataSource source, Dimension size) throws IOException, ImageDecodingException
source
- the source image.IOException
ImageDecodingException
public void setSourceAndDestination(Rect srcArea, Dimension newSize, int createOptions, Dimension trueNewSize)
srcArea
- the source area to decode - this will be adjusted
to fit within the image if it is too large. If it is null then the
entire image is selected.newSize
- the new size of the decoded area. This will be adjusted
if CREATE_OPTION_KEEP_ASPECT_RATIO or CREATE_OPTION_DONT_SCALE_UP is used.createOptions
- any of the CREATE_OPTION_XXX values that affect scaling.trueNewSize
- if this is not null this will hold the final true size of the
image that will be decoded. You would use this if you are sending a possibly null newSize
and/or null srcArea parameter but still want to know what the final size of the
decoded image will be.public void decode(FormattedDataSource source, ImageMaker maker, Rect srcArea, Dimension newSize, int createOptions) throws ImageDecodingException
source
- the data source.maker
- the destination ImageMaker.srcArea
- the area within the source image.ImageDecodingException
public boolean analyze(FormattedDataSource source, ImageInfo destInfo) throws IOException, ImageDecodingException
IOException
ImageDecodingException
public ImageDataInfo getImageDataInfo(ImageDataInfo destInfo)
public void decode(FormattedDataSource source, ImageMaker maker) throws ImageDecodingException
ImageDecodingException
public Picture decodeFully() throws IOException
IOException
public static IImage decodeScaled(FormattedDataSource fds, int newWidth, int newHeight, boolean shouldScale, int scaleOptions, Dimension fullSize, ImageMaker destination) throws IOException, ImageDecodingException
fds
- the source of the image - this will be closed after decoding.newWidth
- the new width of the image if scaled.newHeight
- the new height of the image if scaled.shouldScale
- true to scale the image, false if not to.scaleOptions
- any of the ImageData.CREATE_OPTION_XXX values.fullSize
- an optional dimension to hold the full size of the image.destination
- a destination ImageMaker to hold the data (e.g. a PixelBuffer)
or null to decode and return a Picture.IOException
ImageDecodingException
public static Picture decodeScaledPicture(FormattedDataSource fds, int newWidth, int newHeight, boolean shouldScale, boolean keepAspectRatio, boolean scaleDownOnly, Dimension fullSize) throws IOException, ImageDecodingException
fds
- the source of the image - this will be closed after decoding.newWidth
- the new width of the image if scaled.newHeight
- the new height of the image if scaled.shouldScale
- true to scale the image, false if not to.keepAspectRatio
- true to keep the aspect ratio of the original.scaleDownOnly
- true to only scale down, not up.fullSize
- an optional dimension to hold the full size of the image.IOException
ImageDecodingException
public static Picture decodeScaledPicture(FormattedDataSource fds, Dimension newSize, boolean keepAspectRatio, boolean scaleDownOnly, Dimension fullSize) throws IOException, ImageDecodingException
fds
- the source of the image - this will be closed after decoding.newSize
- the new width and height of the image if scaled, or null for no scaling.keepAspectRatio
- true to keep the aspect ratio of the original.scaleDownOnly
- true to only scale down, not up.fullSize
- an optional dimension to hold the full size of the image.IOException
ImageDecodingException
public void decodeFully(ImageMaker dest) throws IOException
IOException