Class ImageInfo
ImageInfo contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green.
-
Constructor Summary
ConstructorDescriptionCreates an empty ImageInfo withColorInfo.CT_UNKNOWN
,ColorInfo.AT_UNKNOWN
, and a width and height of zero.ImageInfo
(int width, int height) Creates ImageInfo from integral dimensions width and height,ColorInfo.CT_UNKNOWN
andColorInfo.AT_UNKNOWN
.ImageInfo
(int width, int height, int colorType, int alphaType) Creates ImageInfo from integral dimensions width and height, colorType and alphaType.ImageInfo
(int w, int h, int ct, int at, ColorSpace cs) Creates ImageInfo from integral dimensions and ColorInfo, -
Method Summary
Modifier and TypeMethodDescriptionint
Returns alpha type.int
Returns number of bytes per pixel required by ColorType.Returns ColorSpace, the range of colors.int
Returns color type.long
computeByteSize
(int rowBytes) Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes.long
boolean
int
hashCode()
int
height()
Returns pixel row count.boolean
isEmpty()
Returns if ImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.boolean
isOpaque()
Returns true if AlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.boolean
isValid()
Returns if ImageInfo describes an empty area of pixels by checking if width and height is greater than zero, and ColorInfo is valid.static ImageInfo
make
(int width, int height, int ct, int at, ColorSpace cs) Creates ImageInfo from integral dimensions width and height, ColorType ct, AlphaType at, and optionally ColorSpace cs.makeAlphaType
(int newAlphaType) Creates ImageInfo with same ColorSpace, ColorType, width, and height, with AlphaType set to newAlphaType.makeColorSpace
(ColorSpace newColorSpace) Creates ImageInfo with same ColorType, AlphaType, width, and height, with ColorSpace set to newColorSpace.makeColorType
(int newColorType) Creates ImageInfo with same ColorSpace, AlphaType, width, and height, with ColorType set to newColorType.static ImageInfo
makeUnknown
(int width, int height) Creates ImageInfo from integral dimensions width and height,ColorInfo.CT_UNKNOWN
,ColorInfo.AT_UNKNOWN
, with ColorSpace set to null.makeWH
(int newWidth, int newHeight) Creates ImageInfo with the same ColorType and AlphaType, with dimensions set to width and height.int
Returns minimum bytes per row, computed from pixel width() and ColorType, which specifies bytesPerPixel().void
resize
(int width, int height) Internal resize for optimization purposes.toString()
int
width()
Returns pixel count in each row.
-
Constructor Details
-
ImageInfo
public ImageInfo()Creates an empty ImageInfo withColorInfo.CT_UNKNOWN
,ColorInfo.AT_UNKNOWN
, and a width and height of zero. -
ImageInfo
Creates ImageInfo from integral dimensions width and height,ColorInfo.CT_UNKNOWN
andColorInfo.AT_UNKNOWN
.Returned ImageInfo as part of source does not draw, and as part of destination can not be drawn to.
- Parameters:
width
- pixel column count; must be zero or greaterheight
- pixel row count; must be zero or greater
-
ImageInfo
Creates ImageInfo from integral dimensions width and height, colorType and alphaType.Parameters are not validated to see if their values are legal, or that the combination is supported.
- Parameters:
width
- pixel column count; must be zero or greaterheight
- pixel row count; must be zero or greater
-
ImageInfo
@Internal public ImageInfo(@Size(min=0L) int w, @Size(min=0L) int h, int ct, int at, @Nullable ColorSpace cs) Creates ImageInfo from integral dimensions and ColorInfo,Parameters are not validated to see if their values are legal, or that the combination is supported.
- Parameters:
w
- pixel column count; must be zero or greaterh
- pixel row count; must be zero or greater
-
-
Method Details
-
make
@Nonnull public static ImageInfo make(@Size(min=0L) int width, @Size(min=0L) int height, int ct, int at, @Nullable ColorSpace cs) Creates ImageInfo from integral dimensions width and height, ColorType ct, AlphaType at, and optionally ColorSpace cs.If ColorSpace cs is null and ImageInfo is part of drawing source: ColorSpace defaults to sRGB, mapping into Surface ColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
- Parameters:
width
- pixel column count; must be zero or greaterheight
- pixel row count; must be zero or greatercs
- range of colors; may be null
-
makeUnknown
Creates ImageInfo from integral dimensions width and height,ColorInfo.CT_UNKNOWN
,ColorInfo.AT_UNKNOWN
, with ColorSpace set to null.Returned ImageInfo as part of source does not draw, and as part of destination can not be drawn to.
- Parameters:
width
- pixel column count; must be zero or greaterheight
- pixel row count; must be zero or greater
-
resize
@Internal public void resize(int width, int height) Internal resize for optimization purposes. ImageInfo should be created immutable. -
width
public int width()Returns pixel count in each row.- Returns:
- pixel width
-
height
public int height()Returns pixel row count.- Returns:
- pixel height
-
colorType
public int colorType()Returns color type.- Returns:
- color type
-
alphaType
public int alphaType()Returns alpha type.- Returns:
- alpha type
-
colorSpace
Returns ColorSpace, the range of colors.- Returns:
- ColorSpace, or null
-
bytesPerPixel
public int bytesPerPixel()Returns number of bytes per pixel required by ColorType. Returns zero if colorType isColorInfo.CT_UNKNOWN
.- Returns:
- bytes in pixel, bpp
-
minRowBytes
public int minRowBytes()Returns minimum bytes per row, computed from pixel width() and ColorType, which specifies bytesPerPixel(). If rowBytes is greater than IntMax then return 0.- Returns:
- width() times bytesPerPixel() as integer
-
isEmpty
public boolean isEmpty()Returns if ImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.- Returns:
- true if either dimension is zero or smaller
-
isOpaque
public boolean isOpaque()Returns true if AlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.Does not check if ColorType allows alpha, or if any pixel value has transparency.
- Returns:
- true if AlphaType is Opaque
-
isValid
public boolean isValid()Returns if ImageInfo describes an empty area of pixels by checking if width and height is greater than zero, and ColorInfo is valid.- Returns:
- true if both dimension and ColorInfo is valid
-
computeByteSize
public long computeByteSize(int rowBytes) Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes. rowBytes is assumed to be at least as large as minRowBytes().Returns zero if height is zero. Returns LongMax if minRowBytes() is greater than IntMax.
- Parameters:
rowBytes
- size of pixel row or larger- Returns:
- memory required by pixel buffer
-
computeMinByteSize
public long computeMinByteSize() -
makeWH
Creates ImageInfo with the same ColorType and AlphaType, with dimensions set to width and height.- Parameters:
newWidth
- pixel column count; must be zero or greaternewHeight
- pixel row count; must be zero or greater- Returns:
- created ImageInfo
-
makeAlphaType
Creates ImageInfo with same ColorSpace, ColorType, width, and height, with AlphaType set to newAlphaType.- Returns:
- created ImageInfo
-
makeColorType
Creates ImageInfo with same ColorSpace, AlphaType, width, and height, with ColorType set to newColorType.- Returns:
- created ImageInfo
-
makeColorSpace
Creates ImageInfo with same ColorType, AlphaType, width, and height, with ColorSpace set to newColorSpace.- Returns:
- created ImageInfo
-
hashCode
public int hashCode() -
equals
-
toString
-