public class Icon extends IconListObject implements IImage
IIcon.ImageList, IIcon.SizedIcon
Modifier and Type | Field and Description |
---|---|
protected IIcon |
icons |
static int |
IMAGE_TYPE_ALL
An image type for getImages().
|
static int |
IMAGE_TYPE_MIXED_TRANSPARENCIES
An image type for getImages().
|
static int |
IMAGE_TYPE_UNMIXED_TRANSPARENCIES
An image type for getImages().
|
static int |
OPTION_FROM_ICON_FILE_DONT_SEPARATE_TRANSPARENCY
Normally if an icon file has two icons of the same size then the one with the mixed transparency
takes preference and replaces the one that does not.
|
static int |
OPTION_FROM_ICON_FILE_KEEP_COMPRESSED
This tells the Icon to keep a compressed version of the image in storage and only decompress it when needed.
|
static int |
OPTION_FROM_ICON_FILE_LEAVE_IN_RANDOM_STREAM |
static int |
OPTION_FROM_ICON_FILE_TAKE_ALL_ICONS
Normally if an icon file has two icons of the same size then the one with the mixed transparency
takes preference and replaces the one that does not.
|
RAW_IMAGE_ALWAYS_FREE, RAW_IMAGE_DO_NOT_FREE, RAW_IMAGE_FREE_IF_NOT_RETURNED
allowedSizes, defaultIconSizes, oldWindowsDefaultIconSizes
CREATE_OPTION_DONT_SCALE_UP, CREATE_OPTION_IGNORE_ALPHA, CREATE_OPTION_KEEP_ASPECT_RATIO, CREATE_OPTION_ROUGH_SCALING, SCAN_LINE_BYTE_ARRAY, SCAN_LINE_INT_ARRAY, TYPE_ARGB, TYPE_GRAY_SCALE_16, TYPE_GRAY_SCALE_2, TYPE_GRAY_SCALE_256, TYPE_GRAY_SCALE_4, TYPE_INDEXED_16, TYPE_INDEXED_2, TYPE_INDEXED_256, TYPE_INDEXED_4, TYPE_MASK, TYPE_MONO, TYPE_RGB, TYPE_UNKNOWN
ACTIVE, DISABLED, INACTIVE, INDENT_ITEM_FLAG, OUTLINED
MATCH_EXACT, MATCH_SCALE_DOWN, MATCH_SCALE_HEIGHT_PRIORITY, MATCH_SCALE_UP, MATCH_SCALE_WIDTH_PRIORITY
OPTION_DONT_LIMIT_TO_ALLOWED_SIZES, OPTION_GET_DIMENSIONS_ONLY, OPTION_SCALE_DOWN_ONLY, OPTION_SCALE_UP_ONLY
Constructor and Description |
---|
Icon()
If this constructor is used then the getImageList() method can be used to access the Vector
of Images being held by this Object.
|
Icon(IIcon icons)
This is the constructor to use to wrap an existing IIcons object.
|
Icon(ImageData image)
Create a new Icon() for a single ImageData object.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ImageData image)
Add an image directly.
|
void |
add(String name)
Add a named image directly.
|
void |
addCompressed(int width,
int height,
int flags,
ICompressed compressedData)
Add the compressed data directly without copying it.
|
Icon |
addFromICZ(ZepFile src,
int options)
Read and add all the images in the ICZ file.
|
Icon |
addFromImages(Vector imageDataObjects,
int options)
Read and add all the images in the Vector.
|
Icon |
addFromWindowsIcon(RandomStream iconFile,
int options) |
static void |
addImageToICZ(ZepFile dest,
ImageData im,
int flags)
Add an ImageData to the ICZ file.
|
static boolean |
alphaLevelMatchesImageType(int alphaLevel,
int imageType)
Returns if an alpha level value returned from ImageTool.checkAlphaLevel() is compatible
with the imageType specified.
|
void |
clear()
Clear the information and allow the Icon to be reused.
|
static File |
convertToICZ(File parent,
String[] children,
boolean individual)
Convert all the files into an icz file or a set of icz files.
|
int |
countImages()
Count the number of images in the ImageList.
|
static Icon |
decodeFromIconFile(RandomStream iconFile,
int options)
Decode a new Icon from a .icz or .ico file or an image file.
|
static IImage |
deiconize(IImage obj)
If the supplied obj happens to be an Icon then this will convert it to a plain IImage that
does not implement IIcon.
|
void |
draw(Graphics g,
int x,
int y,
int options) |
void |
draw(Graphics g,
int x,
int y,
int width,
int height,
int options) |
void |
draw(Graphics g,
int x,
int y,
int width,
int height,
int drawOptions,
int scaleOptions) |
void |
draw(Graphics g,
int x,
int y,
Rect visibleDestinationArea,
int options)
Draw the Drawable to the Graphics and specify the area on the graphics that is visible.
|
static void |
extractToICZDirectory(File parent,
String[] children,
boolean renameOriginal)
For each file, extract all the images in the file (or the single image if it is an image) into a
directory with a .icz extension in the parent directory.
|
void |
free() |
void |
freeImage()
Free any resource associated with the ImageData object.
|
ImageData[] |
getAllPossibleImages()
An Icon may have separated its mixed and unmixed transparencies.
|
Vector |
getAllPossibleImages(Vector destination)
An Icon may have separated its mixed and unmixed transparencies.
|
Color |
getBackground()
This returns a background color if one is set for the image.
|
static ICompressed |
getCompressedImageData(ZepFile src,
int index) |
static int |
getCompressedImageInfo(ZepFile src,
int index,
Dimension size)
Get the compressed image data.
|
Dimension |
getDimensionsFor(int requestedWidth,
int requestedHeight,
Dimension destination,
int options)
Given a requested width and/or requested height for an IIcon, this returns the dimension that the Drawable
returned by getDrawableFor() will be if called with the same requestedWidth and requestedHeight.
|
Drawable |
getDrawableFor(int width,
int height,
int options)
Return the best icon for the specified requested width and height, at least one of which must be non-zero.
|
static IIcon.ImageList |
getEmptyList()
Get a re-used IIcon.ImageList representing an empty ImageList.
|
int |
getHeight() |
static Icon |
getIcon(String name)
Load an Icon from the ImageCache.
|
IImage |
getImage(int indexOfImage,
PixelBuffer dest)
Get the image at the specified index either by copying into the PixelBuffer provided
or by returning an IImage object.
|
int[] |
getImageColorTable()
For indexed images, this retrieves the color table as an array of ARGB integers.
|
static PixelBuffer |
getImageData(ZepFile src,
int index,
PixelBuffer buffer) |
Dimension |
getImageDimension(int imageIndex,
Dimension dest)
Get the dimensions of the specified image.
|
int |
getImageHeight() |
static int |
getImages(IIcon.ImageList list,
Collection destination)
Place all the images into the destination.
|
Vector |
getImages(int imageType,
Vector destination)
Get all the images of a particular type and place them in the destination.
|
int |
getImageScanLineLength()
If the scan line type is SCAN_LINE_BYTE_ARRAY then this indicates
the number of bytes is needed for one complete scan line.
|
void |
getImageScanLines(int startLine,
int numLines,
Object destArray,
int offset,
int destScanLineLength)
Place a set of scan lines into a destination array.
|
int |
getImageScanLineType()
Get the type of scan line used by the image - either SCAN_LINE_BYTE_ARRAY or SCAN_LINE_INT_ARRAY
|
int |
getImageType()
This returns one of the TYPE_XXX values
|
int |
getImageWidth() |
IIcon.ImageList |
getMixedTransparencyImages() |
int[] |
getPixels(int[] dest,
int offset,
int x,
int y,
int width,
int height,
int rowStride)
Retrieve the pixels from the Image in encoded ARGB values.
|
IIcon.ImageList |
getUnmixedTransparencyImages() |
int |
getWidth() |
boolean |
hasExactMatchFor(int width,
int height)
Returns true if this IIcons considers itself to have an exact match for the requested size.
|
boolean |
isReadableImage()
Returns if you can read data from the ImageData.
|
boolean |
isWriteableImage()
Returns if you can write data to the ImageData.
|
static Icon |
load(String names,
Icon defaultIcon)
Load an Icon from the ImageCache.
|
void |
releaseGetImage(IImage im)
Call this if you no longer need the image returned by getImage().
|
void |
setCompressed(boolean compressed)
Set whether image data should be compressed within the Icon.
|
void |
setImageScanLines(int startLine,
int numLines,
Object sourceArray,
int offset,
int sourceScanLineLength)
Place a set of scan lines from a source Array into the ImageData.
|
void |
setMixedTransparencyImages(IIcon.ImageList im) |
boolean |
setPixels(int[] src,
int offset,
int x,
int y,
int width,
int height,
int rowStride)
Set the pixels in the IImage in encoded ARGB values.
|
void |
setUnmixedTransparencyImages(IIcon.ImageList im) |
static DeviceIcon |
toDeviceIcon(Object obj)
Create a DeviceIcon from the specified object.
|
static ByteArray |
toICO(ImageData[] images,
int imageType) |
ByteArray |
toICO(int imageType) |
static Icon |
toIcon(Object obj,
Icon reused)
If the supplied object is not an Icon() object, then wrap it in an Icon() object and return it.
|
static ByteArray |
toICZ(File dir)
Convert all image files in the directory to a .icz file.
|
static ByteArray |
toICZ(ImageData[] images)
Place images in an ICZ file.
|
ZepFile |
toICZ(int imageType,
ZepFile dest)
Add specific images of a specific type in this Icon to an ICZ formatted ZepFile.
|
static Object |
toIIcon(Object got) |
static IIcon |
toIIcon(Object obj,
Icon reused)
If the supplied object is not an IIcon() object, then wrap it in an Icon() object and return it.
|
static IIcon.ImageList |
toImageList(Object obj,
Icon reused)
Convert an Object into an Object that implements IIcon.ImageList.
|
static IImage |
toSizedImage(Object obj,
int width,
int height)
Create a fixed size image from a possible IIcon or IIcon.ImageList or IImage.
|
boolean |
usesAlpha()
Returns whether the image uses the Alpha channel.
|
addedImage, getBestScaledIcon, getHeightFor, getImageFlags, getMatchFor, getScaleAndCacheFor, getScaled, getWidthFor, hasMixedTransparencyImages, setImageModifier
adjustHeight, adjustWidth, cacheDimension, cacheImage, getAllowedSizeFor, getCachedDimension, getCachedImage, getDrawableFor, releaseDrawable
protected IIcon icons
public static final int IMAGE_TYPE_MIXED_TRANSPARENCIES
public static final int IMAGE_TYPE_UNMIXED_TRANSPARENCIES
public static final int IMAGE_TYPE_ALL
public static final int OPTION_FROM_ICON_FILE_KEEP_COMPRESSED
public static final int OPTION_FROM_ICON_FILE_TAKE_ALL_ICONS
public static final int OPTION_FROM_ICON_FILE_DONT_SEPARATE_TRANSPARENCY
public static final int OPTION_FROM_ICON_FILE_LEAVE_IN_RANDOM_STREAM
public Icon(ImageData image)
image
- the image to add. This is converted to an IImage using ImageAdapter.public Icon()
public Icon(IIcon icons)
icons
- the non-null IIcons object.public static IIcon.ImageList getEmptyList()
public void setCompressed(boolean compressed) throws IllegalStateException
IllegalStateException
public void clear()
clear
in class IconListObject
public static int getImages(IIcon.ImageList list, Collection destination)
list
- the list of images.destination
- a destination collection.public static boolean alphaLevelMatchesImageType(int alphaLevel, int imageType)
alphaLevel
- an alpha level value returned from ImageTool.checkAlphaLevel()imageType
- any of the IMAGE_TYPE_XXX values OR'ed together.public Vector getImages(int imageType, Vector destination)
imageType
- the type of the image, any of the IMAGE_TYPE_XXX values OR'ed together.destination
- a Vector or null to create and return a new one.public Vector getAllPossibleImages(Vector destination)
destination
- a destination Vector. If this is null a new Vector is created and returned.public ImageData[] getAllPossibleImages()
public static DeviceIcon toDeviceIcon(Object obj)
obj
- an IIcon or IIcon.ImageList or ImageData object.public static IImage toSizedImage(Object obj, int width, int height)
obj
- the object to get the best sized image from.width
- the requested width. This can be zero if height is not zero.height
- the requested height. This can be zero if width is not zero.public static IIcon.ImageList toImageList(Object obj, Icon reused)
obj
- this can be a String, in which case it is loaded and returned as an ImageList with a single image.
If it is an IIcon then a single 32x32 version of it is placed in an ImageList.reused
- an optional Icon to use for the conversion. This may or may not be used.public static IIcon toIIcon(Object obj, Icon reused)
obj
- an Object that implements either ImageData or IIcons.public static Icon toIcon(Object obj, Icon reused)
obj
- an Object that implements either ImageData or IIcons or IIcons.ImageList.public static Icon getIcon(String name)
name
- the name of the image.public static IImage deiconize(IImage obj)
obj
- a possible Icon object.public void setMixedTransparencyImages(IIcon.ImageList im)
public void setUnmixedTransparencyImages(IIcon.ImageList im)
public IIcon.ImageList getMixedTransparencyImages()
public IIcon.ImageList getUnmixedTransparencyImages()
public static Icon load(String names, Icon defaultIcon)
names
- defaultIcon
- public void add(ImageData image) throws IllegalStateException
image
- the image to add. It will be converted to an IImage if necessary.IllegalStateException
public void add(String name) throws IllegalStateException
image
- the image to add. It will be converted to an IImage if necessary.IllegalStateException
public void addCompressed(int width, int height, int flags, ICompressed compressedData) throws IllegalStateException
width
- height
- compressedData
- IllegalStateException
public Color getBackground()
IImage
getBackground
in interface IImage
public boolean usesAlpha()
IImage
public void freeImage()
ImageData
public int[] getImageColorTable()
ImageData
getImageColorTable
in interface ImageData
public int getImageHeight()
getImageHeight
in interface ImageData
public int getImageScanLineLength()
ImageData
getImageScanLineLength
in interface ImageData
public int getImageScanLineType()
ImageData
getImageScanLineType
in interface ImageData
public void getImageScanLines(int startLine, int numLines, Object destArray, int offset, int destScanLineLength) throws IllegalStateException
ImageData
getImageScanLines
in interface ImageData
IllegalStateException
public int getImageType()
ImageData
getImageType
in interface ImageData
public int getImageWidth()
getImageWidth
in interface ImageData
public int[] getPixels(int[] dest, int offset, int x, int y, int width, int height, int rowStride)
ImageData
getPixels
in interface ImageData
dest
- The destination int array. If this is null then a new array should be created.offset
- The offset into the array to start placing pixels.x
- the x co-ordinate within the image.y
- the y co-ordinate within the image.width
- the width of the pixel block to get.height
- the height of the pixel block to get.rowStride
- the number of int values between each row in the destination int array. If this is 0 it
will be assumed to be equal to width.public boolean isReadableImage()
ImageData
isReadableImage
in interface ImageData
public boolean isWriteableImage()
ImageData
isWriteableImage
in interface ImageData
public void setImageScanLines(int startLine, int numLines, Object sourceArray, int offset, int sourceScanLineLength) throws IllegalStateException
ImageData
setImageScanLines
in interface ImageData
IllegalStateException
public boolean setPixels(int[] src, int offset, int x, int y, int width, int height, int rowStride)
ImageData
setPixels
in interface ImageData
src
- The source int array.offset
- The offset into the array to start retrieving pixels.x
- the x co-ordinate within the image.y
- the y co-ordinate within the image.width
- the width of the pixel block to get.height
- the height of the pixel block to get.rowStride
- the number of int values between each row in the source int array. If this is 0 it
will be assumed to be equal to width.public void draw(Graphics g, int x, int y, int options)
public void draw(Graphics g, int x, int y, int width, int height, int options)
public Drawable getDrawableFor(int width, int height, int options)
IIcon
getDrawableFor
in interface IIcon
width
- the requested width. This can be zero to indicate that it is not specified, if requestedHeight is non-zero.height
- the requested height. This can be zero to indicate that it is not specified, if requestedWidth is non-zero.options
- options for getting the image.public boolean hasExactMatchFor(int width, int height)
IIcon
hasExactMatchFor
in interface IIcon
hasExactMatchFor
in class IconListObject
width
- the width to match or 0 to match only the height.height
- the height to match or 0 to match only the width.public void draw(Graphics g, int x, int y, int width, int height, int drawOptions, int scaleOptions)
draw
in interface IIcon
draw
in class IconObject
public Dimension getDimensionsFor(int requestedWidth, int requestedHeight, Dimension destination, int options)
IIcon
getDimensionsFor
in interface IIcon
getDimensionsFor
in class IconListObject
requestedWidth
- the requested width. This can be zero to indicate that it is not specified, if requestedHeight is non-zero.requestedHeight
- the requested height. This can be zero to indicate that it is not specified, if requestedWidth is non-zero.destination
- a destination Dimension or null to return a new one.options
- any combination of the OPTION_XXX values - which the IIcon may choose to ignore.public int countImages()
IIcon.ImageList
countImages
in interface IIcon.ImageList
countImages
in class IconListObject
public void releaseGetImage(IImage im)
IIcon.ImageList
releaseGetImage
in interface IIcon.ImageList
im
- the image returned by getImage().public IImage getImage(int indexOfImage, PixelBuffer dest)
IIcon.ImageList
getImage
in interface IIcon.ImageList
indexOfImage
- the index of the image to fetch.dest
- an optional PixelBuffer destination. If this is NOT null, it will be
resized and set to the Image at the specified index.public Dimension getImageDimension(int imageIndex, Dimension dest)
IIcon.ImageList
getImageDimension
in interface IIcon.ImageList
getImageDimension
in class IconListObject
dest
- the destination Dimension or null to create and return a new one.public static void addImageToICZ(ZepFile dest, ImageData im, int flags)
dest
- a destination ZepFile that was created for saving images.im
- the image to add to the ICZ file.flags
- if the alpha level of the ImageData is not known, set this to ImageTool.ALPHA_LEVEL_UNKNOWN,
otherwise set it to the alpha level of the image.public static int getCompressedImageInfo(ZepFile src, int index, Dimension size) throws CorruptedDataException
src
- the src ZepFile in the ICZ format.index
- the index of the image in the ICZ format file.size
- a non-null Dimension object that will hold the size of the image at the specified index.CorruptedDataException
public static ICompressed getCompressedImageData(ZepFile src, int index) throws CorruptedDataException
CorruptedDataException
public static PixelBuffer getImageData(ZepFile src, int index, PixelBuffer buffer) throws CorruptedDataException
CorruptedDataException
public Icon addFromICZ(ZepFile src, int options) throws IOException
src
- the ICZFile.options
- any of the OPTION_FROM_ICON_FILE_XXX values ORed together.IOException
public Icon addFromImages(Vector imageDataObjects, int options) throws IOException
imageDataObjects
- a Vector of ImageData objects.options
- any of the OPTION_FROM_ICON_FILE_XXX values ORed together.IOException
public Icon addFromWindowsIcon(RandomStream iconFile, int options) throws IOException
IOException
public static Icon decodeFromIconFile(RandomStream iconFile, int options) throws IOException
iconFile
- the Icon or image file opened as a RandomStream.options
- any of the OPTION_FROM_ICON_FILE_XXX values OR'ed together.IOException
public static void extractToICZDirectory(File parent, String[] children, boolean renameOriginal) throws IOException
parent
- the parent file.children
- the files to extract.IOException
public static File convertToICZ(File parent, String[] children, boolean individual) throws IOException, StoppedException
parent
- children
- individual
- IOException
StoppedException
public static ByteArray toICZ(ImageData[] images)
images
- the images to place in the file.public ZepFile toICZ(int imageType, ZepFile dest)
imageType
- one of the IMAGE_TYPE_XXX values.dest
- an optional destination ZepFile.public ByteArray toICO(int imageType)
public static ByteArray toICZ(File dir) throws IOException
dir
- the directory.IOException
public void draw(Graphics g, int x, int y, Rect visibleDestinationArea, int options)
Drawable
draw
in interface Drawable
g
- the Graphics to draw to.x
- the x-location on the graphics to draw to.y
- the y-location on the graphics to draw to.visibleDestinationArea
- the area that will be updated on the Graphics. If this is null
then assume that all of the Drawable must be drawn.options
- any of the Drawable options OR'ed together.