public class Pixmap
extends java.lang.Object
Pixmap
object allows you to access a Cumulus pixmap field.Modifier and Type | Class and Description |
---|---|
static class |
Pixmap.AssetInfo
Wraps asset information.
|
static class |
Pixmap.JPEGInfo
Wraps image information.
|
Modifier and Type | Field and Description |
---|---|
static int |
High
Value of the high image quality.
|
static int |
JPEG
Value of the compression for JPEG compressed images.
|
static int |
LZW
Value of the compression for LZW compressed images.
|
static int |
Monochrome
Value of the color mode for grayscale images.
|
static int |
Normal
Value of the normal image quality.
|
static int |
PNG
Value of the compression for PNG compressed images.
|
static int |
RGBColor
Value of the color mode for color images.
|
static int |
UNCOMPRESSED
Value of the compression for uncompressed images.
|
Constructor and Description |
---|
Pixmap()
Creates a new empty
Pixmap object. |
Pixmap(byte[] packData)
Creates a new
Pixmap object from a pack byte array. |
Pixmap(JPack pack)
Creates a new
Pixmap object from a pack. |
Modifier and Type | Method and Description |
---|---|
static Pixmap |
createFromAsset(Asset asset,
java.lang.String assetHandlingSet)
Creates a pixel preview for the given asset.
|
static Pixmap |
createFromAsset(Asset asset,
java.lang.String assetHandlingSet,
int maxSize,
int rotation)
Creates a pixel preview for the given asset.
|
static Pixmap |
createFromAsset(Asset asset,
java.lang.String assetHandlingSet,
int maxSizeWidth,
int maxSizeHeight,
int rotation)
Creates a pixel preview for the given asset.
|
static Pixmap |
createPixmapFromJPEG(byte[] jpgBytes)
Creates a new Pixmap object from a JPG stream given as a byte array.
|
static Pixmap |
createPixmapFromPNG(byte[] pngBytes)
Creates a new Pixmap object from a PNG stream given as a byte array.
|
static Pixmap |
createPixmapFromPNG(java.io.InputStream PNGStream)
Creates a new Pixmap object from a PNG stream.
|
java.awt.image.BufferedImage |
getAsImage(CumulusSession session,
Item item,
boolean extendImageAreaToBoundingBox,
int maxSizeWidth,
int maxSizeHeight,
int rotation)
Return AWT image which optionally embeds the assets metadata tags.
|
byte[] |
getAsJPEG()
Returns the pixels as JPEG compressed data.
|
byte[] |
getAsJPEG(CumulusSession session,
int maxSize,
int rotation,
int quality) |
byte[] |
getAsJPEG(int maxSize)
Returns the pixels as JPEG compressed data.
|
byte[] |
getAsJPEG(int maxSize,
int rotation,
int quality)
Returns the pixels as JPEG compressed data.
|
byte[] |
getAsJPEG(Item item,
CumulusSession cumulusSession,
int maxWidth,
int maxHeight,
int rotation,
int quality)
Return JPEG image which optionally embeds the assets metadata tags.
|
byte[] |
getAsJPEG(Item item,
int maxSize,
int rotation,
int quality)
Return JPEG image which optionally embeds the assets metadata tags.
|
byte[] |
getAsPNG(int maxSize,
int rotation)
Returns the pixels as PNG compressed data.
|
byte[] |
getAsPNG(int maxSizeWidth,
int maxSizeHeight,
int rotation)
Returns the pixels as PNG compressed data.
|
static Pixmap.AssetInfo |
getAssetInfo(Asset asset)
Reads the image size and bitdepth if the given asset uses a supported format.
|
int |
getBitsPerPixel()
Returns the number of bits per pixel.
|
int |
getColorMode()
Returns the color mode.
|
int |
getCompressMethod()
Returns the compression method.
|
byte[] |
getData()
Returns the compressed pixel data.
|
int |
getHeight()
Returns the height of the image.
|
JPack |
getJPack()
Returns the internal data pack for this pixmap.
|
int |
getQuality()
Returns the image quality of the picture.
|
int |
getWidth()
Returns the width of the image.
|
boolean |
hasValue()
Return whether this Pixmap object holds a real image.
|
void |
optimize()
Optimize brightness and contrast.
|
static Pixmap.JPEGInfo |
readJPEGInfoFromAsset(Asset asset)
Reads the image size and bitdepth if the given asset references an accessible JPEG asset.
|
void |
rotate(int rotation)
Rotate the pixmap by a multiple of 90 degrees.
|
static void |
rotateJpeg(InputDataStream inStream,
OutputDataStream outStream,
int rotation,
int quality)
Rotates a JPEG image by multiples of 90 degrees clockwise.
|
public static final int Monochrome
getColorMode()
,
Constant Field Valuespublic static final int RGBColor
getColorMode()
,
Constant Field Valuespublic static final int UNCOMPRESSED
getCompressMethod()
,
Constant Field Valuespublic static final int LZW
getCompressMethod()
,
Constant Field Valuespublic static final int JPEG
getCompressMethod()
,
Constant Field Valuespublic static final int PNG
getCompressMethod()
,
Constant Field Valuespublic static final int Normal
getQuality()
,
Constant Field Valuespublic static final int High
getQuality()
,
Constant Field Valuespublic Pixmap(byte[] packData)
Pixmap
object from a pack byte array.
Fields fields = records.getRecord(index).getFields (); Field field = field.getFieldByID(GUID.UID_REC_THUMBNAIL); Pixmap pixmap = new Pixmap ((byte[]) f.getValue()); Image image = Toolkit.getDefaultToolkit().createImage(pixmap.getData()); ImageIcon imageIcon = new ImageIcon(image);
packData
- a pack byte array obtained from a call to Item.getPictureValue(GUID)
.public Pixmap(JPack pack)
Pixmap
object from a pack.pack
- a pixmap packpublic Pixmap()
Pixmap
object.public boolean hasValue()
true
if this object holds a valid image. Return false
otherwise.public static Pixmap createPixmapFromJPEG(byte[] jpgBytes)
jpgBytes
- a JPG stream.public static Pixmap createPixmapFromPNG(java.io.InputStream PNGStream)
PNGStream
- a PNG stream.public static Pixmap createPixmapFromPNG(byte[] pngBytes)
pngBytes
- a PNG stream.public JPack getJPack()
public int getWidth() throws CumulusException
CumulusException
- if the information is not available.public int getHeight() throws CumulusException
CumulusException
- if the information is not available.public int getBitsPerPixel() throws CumulusException
CumulusException
- if the information is not available.public int getColorMode() throws CumulusException
CumulusException
- if the information is not available.public int getCompressMethod() throws CumulusException
CumulusException
- if the information is not available.public byte[] getData() throws CumulusException
CumulusException
- if the information is not available.public byte[] getAsJPEG() throws CumulusException
CumulusException
- if the information is not available.public byte[] getAsJPEG(int maxSize) throws CumulusException
maxSize
- maximum number of pixels for width and height.CumulusException
- if an error occurred.public byte[] getAsJPEG(int maxSize, int rotation, int quality) throws CumulusException
maxSize
- maximum number of pixels for width and height.rotation
- number of times to rotate by 90 degrees clockwise.quality
- the quality used for JPEG compression. Possible values are between 1 (lowest) and 10 (best).CumulusException
- if an error occurred.public byte[] getAsJPEG(CumulusSession session, int maxSize, int rotation, int quality) throws CumulusException
CumulusException
public byte[] getAsJPEG(Item item, int maxSize, int rotation, int quality) throws CumulusException
item
- provider for the metadata tags to embedmaxSize
- maximum number of pixels for width and height.rotation
- number of times to rotate by 90 degrees clockwise.quality
- the quality used for JPEG compression. Possible values are between 1 (lowest) and 10 (best).CumulusException
- if an error occurred.public byte[] getAsJPEG(Item item, CumulusSession cumulusSession, int maxWidth, int maxHeight, int rotation, int quality) throws CumulusException
item
- provider for the metadata tags to embed or null
if no metadata tags should be embeddedcumulusSession
- session specifying the user configuration for displaying pattern background for transparent images, or null
if you don't
want to see the pattern backgroundmaxWidth
- maximum number of pixels for width.maxHeight
- maximum number of pixels for height.rotation
- number of times to rotate by 90 degrees clockwise.quality
- the quality used for JPEG compression. Possible values are between 1 (lowest) and 10 (best).CumulusException
- if an error occurred.public java.awt.image.BufferedImage getAsImage(CumulusSession session, Item item, boolean extendImageAreaToBoundingBox, int maxSizeWidth, int maxSizeHeight, int rotation) throws CumulusException
session
- used to determine the background transparency grid configuration for transparent images. Can be null
if no
transparency grid should be painteditem
- provider for the metadata tags to embed or null
if no metadata tags should be embedded.extendImageAreaToBoundingBox
- expand the scaled image to the complete bounding box area. When this parameter is true
, the returned image
will always be a square with the maxSize as edge length, otherwise the returned image will keep the aspect ratio of
the source pixmap.maxSizeWidth
- maximum number of pixels for width.maxSizeHeight
- maximum number of pixels for height.rotation
- number of times to rotate by 90 degrees clockwise.CumulusException
- if an error occurred.public byte[] getAsPNG(int maxSize, int rotation) throws CumulusException
maxSize
- maximum number of pixels for width and height.rotation
- number of times to rotate by 90 degrees clockwise.CumulusException
- if an error occurred.public byte[] getAsPNG(int maxSizeWidth, int maxSizeHeight, int rotation) throws CumulusException
maxSizeWidth
- maximum number of pixels for width.maxSizeHeight
- maximum number of pixels for height.rotation
- number of times to rotate by 90 degrees clockwise.CumulusException
- if an error occurred.public int getQuality() throws CumulusException
CumulusException
- if the information is not available.public static void rotateJpeg(InputDataStream inStream, OutputDataStream outStream, int rotation, int quality) throws CumulusException
inStream
- an input stream of source the JPEG image data.outStream
- an output stream of source the JPEG image data.rotation
- number of times to rotate by 90 degrees clockwise.quality
- the quality used for JPEG compression. Possible values are between 1 (lowest) and 10 (best).CumulusException
- if the image cannot be rotated.public static Pixmap.JPEGInfo readJPEGInfoFromAsset(Asset asset) throws CumulusException
asset
- the JPEG asset to read the information from.CumulusException
- if the asset is not accessible or not a valid JPEG image.public static Pixmap.AssetInfo getAssetInfo(Asset asset) throws CumulusException
asset
- the asset to read the information fromCumulusException
- if the asset is not accessible or not a valid formatpublic static Pixmap createFromAsset(Asset asset, java.lang.String assetHandlingSet) throws CumulusException
asset
- the asset to create the preview for.assetHandlingSet
- the name of the asset handling set to use. Specify null
to use the default set.CumulusException
- if the asset is not accessible or the format is not supportedpublic static Pixmap createFromAsset(Asset asset, java.lang.String assetHandlingSet, int maxSize, int rotation) throws CumulusException
asset
- the asset to create the preview for.assetHandlingSet
- the name of the asset handling set to use. Specify null
to use the default set.maxSize
- maximum size of the preview in pixels. Specify 0
to create a preview in the native size.rotation
- number of times to rotate by 90 degrees clockwise.CumulusException
- if the asset is not accessible or the format is not supportedpublic static Pixmap createFromAsset(Asset asset, java.lang.String assetHandlingSet, int maxSizeWidth, int maxSizeHeight, int rotation) throws CumulusException
asset
- the asset to create the preview for.assetHandlingSet
- the name of the asset handling set to use. Specify null
to use the default set.maxSizeWidth
- maximum size of the preview width in pixels. Specify 0
to create a preview in the native size.maxSizeHeight
- maximum size of the preview height in pixels. Specify 0
to create a preview in the native size.rotation
- number of times to rotate by 90 degrees clockwise.CumulusException
- if the asset is not accessible or the format is not supportedpublic void optimize()
public void rotate(int rotation)
rotation
- number of times to rotate by 90 degrees clockwise.www.canto.com
Canto, the Canto logo, the Cumulus logo, and Cumulus are registered trademarks of Canto GmbH, registered in the U.S. and other countries.