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
ConstructorsConstructorDescriptionCreates 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_UNKNOWNandColorInfo.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, @Nullable ColorSpace cs) Creates ImageInfo from integral dimensions and ColorInfo, -
Method Summary
Modifier and TypeMethodDescriptionintReturns alpha type.intReturns number of bytes per pixel required by ColorType.@Nullable ColorSpaceReturns ColorSpace, the range of colors.intReturns color type.longcomputeByteSize(int rowBytes) Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes.longbooleaninthashCode()intheight()Returns pixel row count.booleanisEmpty()Returns if ImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.booleanisOpaque()Returns true if AlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.booleanisValid()Returns if ImageInfo describes an empty area of pixels by checking if width and height is greater than zero, and ColorInfo is valid.static @NonNull ImageInfomake(int width, 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.@NonNull ImageInfomakeAlphaType(int newAlphaType) Creates ImageInfo with same ColorSpace, ColorType, width, and height, with AlphaType set to newAlphaType.@NonNull ImageInfomakeColorSpace(@Nullable ColorSpace newColorSpace) Creates ImageInfo with same ColorType, AlphaType, width, and height, with ColorSpace set to newColorSpace.@NonNull ImageInfomakeColorType(int newColorType) Creates ImageInfo with same ColorSpace, AlphaType, width, and height, with ColorType set to newColorType.static @NonNull ImageInfomakeUnknown(int width, int height) Creates ImageInfo from integral dimensions width and height,ColorInfo.CT_UNKNOWN,ColorInfo.AT_UNKNOWN, with ColorSpace set to null.@NonNull ImageInfomakeWH(int newWidth, int newHeight) Creates ImageInfo with the same ColorType and AlphaType, with dimensions set to width and height.intReturns minimum bytes per row, computed from pixel width() and ColorType, which specifies bytesPerPixel().voidresize(int width, int height) Internal resize for optimization purposes.toString()intwidth()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_UNKNOWNandColorInfo.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
public static @NonNull 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
-