Class ImageInfo
- java.lang.Object
-
- io.github.humbleui.skija.ImageInfo
-
public class ImageInfo extends java.lang.ObjectDescribes pixel dimensions and encoding. Bitmap, Image, Pixmap, and Surface can be created from ImageInfo. ImageInfo can be retrieved from Bitmap and Pixmap, but not from Image and Surface. For example, Image and Surface implementations may defer pixel depth, so may not completely specify ImageInfo.
ImageInfo contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and ColorSpace, the range and linearity of colors.
-
-
Constructor Summary
Constructors Constructor Description ImageInfo(int width, int height, int colorType, int alphaType, long colorSpace)ImageInfo(int width, int height, @NotNull ColorType colorType, @NotNull ColorAlphaType alphaType)ImageInfo(int width, int height, @NotNull ColorType colorType, @NotNull ColorAlphaType alphaType, @Nullable ColorSpace colorSpace)ImageInfo(ColorInfo colorInfo, int width, int height)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)longcomputeByteSize(long rowBytes)Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes.longcomputeMinByteSize()Returns storage required by pixel array, given ImageInfo dimensions, and ColorType.longcomputeOffset(int x, int y, long rowBytes)Returns byte offset of pixel from pixel base address.booleanequals(java.lang.Object o)@NotNull io.github.humbleui.types.IRectgetBounds()intgetBytesPerPixel()Returns number of bytes per pixel required by ColorType.@NotNull ColorAlphaTypegetColorAlphaType()ColorInfogetColorInfo()@Nullable ColorSpacegetColorSpace()@NotNull ColorTypegetColorType()intgetHeight()longgetMinRowBytes()Returns minimum bytes per row, computed from pixel getWidth() and ColorType, which specifies getBytesPerPixel().intgetShiftPerPixel()Returns bit shift converting row bytes to row pixels.intgetWidth()inthashCode()booleanisEmpty()booleanisGammaCloseToSRGB()booleanisOpaque()Returns true if ColorAlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.booleanisRowBytesValid(long rowBytes)Returns true if rowBytes is valid for this ImageInfo.static @NotNull ImageInfomakeA8(int width, int height)static @NotNull ImageInfomakeN32(int width, int height, @NotNull ColorAlphaType alphaType)static @NotNull ImageInfomakeN32(int width, int height, @NotNull ColorAlphaType alphaType, @Nullable ColorSpace colorSpace)static @NotNull ImageInfomakeN32Premul(int width, int height)static @NotNull ImageInfomakeN32Premul(int width, int height, @Nullable ColorSpace colorSpace)static @NotNull ImageInfomakeS32(int width, int height, @NotNull ColorAlphaType alphaType)static @NotNull ImageInfomakeUnknown(int width, int height)java.lang.StringtoString()@NotNull ImageInfowithColorAlphaType(@NotNull ColorAlphaType alphaType)ImageInfowithColorInfo(ColorInfo _colorInfo)@NotNull ImageInfowithColorSpace(@NotNull ColorSpace colorSpace)@NotNull ImageInfowithColorType(@NotNull ColorType colorType)ImageInfowithHeight(int _height)ImageInfowithWidth(int _width)@NotNull ImageInfowithWidthHeight(int width, int height)
-
-
-
Constructor Detail
-
ImageInfo
public ImageInfo(int width, int height, @NotNull @NotNull ColorType colorType, @NotNull @NotNull ColorAlphaType alphaType)
-
ImageInfo
public ImageInfo(int width, int height, @NotNull @NotNull ColorType colorType, @NotNull @NotNull ColorAlphaType alphaType, @Nullable @Nullable ColorSpace colorSpace)
-
ImageInfo
@Internal public ImageInfo(int width, int height, int colorType, int alphaType, long colorSpace)
-
ImageInfo
public ImageInfo(ColorInfo colorInfo, int width, int height)
-
-
Method Detail
-
makeN32
@NotNull @Contract("_, _, _ -> new") public static @NotNull ImageInfo makeN32(int width, int height, @NotNull @NotNull ColorAlphaType alphaType)- Returns:
- ImageInfo with
ColorType.N32
-
makeN32
@NotNull @Contract("_, _, _, _ -> new") public static @NotNull ImageInfo makeN32(int width, int height, @NotNull @NotNull ColorAlphaType alphaType, @Nullable @Nullable ColorSpace colorSpace)- Returns:
- ImageInfo with
ColorType.N32
-
makeS32
@NotNull @Contract("_, _, _ -> new") public static @NotNull ImageInfo makeS32(int width, int height, @NotNull @NotNull ColorAlphaType alphaType)- Returns:
- ImageInfo with
ColorType.N32andColorSpace.getSRGB() - See Also:
- https://fiddle.skia.org/c/@ImageInfo_MakeS32
-
makeN32Premul
@NotNull @Contract("_, _ -> new") public static @NotNull ImageInfo makeN32Premul(int width, int height)- Returns:
- ImageInfo with
ColorType.N32andColorAlphaType.PREMUL
-
makeN32Premul
@NotNull @Contract("_, _, _ -> new") public static @NotNull ImageInfo makeN32Premul(int width, int height, @Nullable @Nullable ColorSpace colorSpace)- Returns:
- ImageInfo with
ColorType.N32andColorAlphaType.PREMUL
-
makeA8
@NotNull @Contract("_, _ -> new") public static @NotNull ImageInfo makeA8(int width, int height)- Returns:
- ImageInfo with
ColorType.ALPHA_8andColorAlphaType.PREMUL
-
makeUnknown
@NotNull @Contract("_, _ -> new") public static @NotNull ImageInfo makeUnknown(int width, int height)- Returns:
- ImageInfo with
ColorType.UNKNOWNandColorAlphaType.UNKNOWN
-
getColorType
@NotNull public @NotNull ColorType getColorType()
-
withColorType
@NotNull public @NotNull ImageInfo withColorType(@NotNull @NotNull ColorType colorType)
-
getColorAlphaType
@NotNull public @NotNull ColorAlphaType getColorAlphaType()
-
withColorAlphaType
@NotNull public @NotNull ImageInfo withColorAlphaType(@NotNull @NotNull ColorAlphaType alphaType)
-
getColorSpace
@Nullable public @Nullable ColorSpace getColorSpace()
-
withColorSpace
@NotNull public @NotNull ImageInfo withColorSpace(@NotNull @NotNull ColorSpace colorSpace)
-
isEmpty
public boolean isEmpty()
- Returns:
- true if either dimension is zero or smaller
-
isOpaque
public boolean isOpaque()
Returns true if ColorAlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0. If true, and all pixels are not opaque, Skia may draw incorrectly.
Does not check if ColorType allows alpha, or if any pixel value has transparency.
- Returns:
- true if alphaType is
ColorAlphaType.OPAQUE
-
getBounds
@NotNull public @NotNull io.github.humbleui.types.IRect getBounds()
- Returns:
- integral rectangle from (0, 0) to (getWidth(), getHeight())
-
isGammaCloseToSRGB
public boolean isGammaCloseToSRGB()
- Returns:
- true if associated ColorSpace is not null, and ColorSpace gamma is approximately the same as sRGB.
-
withWidthHeight
@NotNull public @NotNull ImageInfo withWidthHeight(int width, int height)
-
getBytesPerPixel
public int getBytesPerPixel()
Returns number of bytes per pixel required by ColorType. Returns zero ifgetColorType()isColorType.UNKNOWN.- Returns:
- bytes in pixel
-
getShiftPerPixel
public int getShiftPerPixel()
Returns bit shift converting row bytes to row pixels. Returns zero forColorType.UNKNOWN.- Returns:
- one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes
-
getMinRowBytes
public long getMinRowBytes()
Returns minimum bytes per row, computed from pixel getWidth() and ColorType, which specifies getBytesPerPixel(). Bitmap maximum value for row bytes must fit in 31 bits.
-
computeOffset
public long computeOffset(int x, int y, long rowBytes)Returns byte offset of pixel from pixel base address.
Asserts in debug build if x or y is outside of bounds. Does not assert if rowBytes is smaller than
getMinRowBytes(), even though result may be incorrect.- Parameters:
x- column index, zero or greater, and less than getWidth()y- row index, zero or greater, and less than getHeight()rowBytes- size of pixel row or larger- Returns:
- offset within pixel array
- See Also:
- https://fiddle.skia.org/c/@ImageInfo_computeOffset
-
computeByteSize
public long computeByteSize(long rowBytes)
Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes. rowBytes is assumed to be at least as large as
getMinRowBytes().Returns zero if height is zero.
- Parameters:
rowBytes- size of pixel row or larger- Returns:
- memory required by pixel buffer
- See Also:
- https://fiddle.skia.org/c/@ImageInfo_computeByteSize
-
computeMinByteSize
public long computeMinByteSize()
Returns storage required by pixel array, given ImageInfo dimensions, and ColorType. Uses
Returns zero if height is zero.getMinRowBytes()to compute bytes for pixel row.- Returns:
- least memory required by pixel buffer
-
isRowBytesValid
public boolean isRowBytesValid(long rowBytes)
Returns true if rowBytes is valid for this ImageInfo.- Parameters:
rowBytes- size of pixel row including padding- Returns:
- true if rowBytes is large enough to contain pixel row and is properly aligned
-
getColorInfo
public ColorInfo getColorInfo()
-
getWidth
public int getWidth()
-
getHeight
public int getHeight()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withWidth
public ImageInfo withWidth(int _width)
- Returns:
this.
-
withHeight
public ImageInfo withHeight(int _height)
- Returns:
this.
-
-