Package icyllis.arc3d.core

# Class ImageInfo

java.lang.Object
icyllis.arc3d.core.ImageInfo

public final class ImageInfo extends Object
Describes pixel dimensions and encoding.

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

  Constructors
  Constructor
  Description
  `ImageInfo()`
  Creates an empty ImageInfo with `ColorInfo.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` and `ColorInfo.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 Type
  Method
  Description
  `int`
  `alphaType()`
  Returns alpha type.
  `int`
  `bytesPerPixel()`
  Returns number of bytes per pixel required by ColorType.
  `ColorSpace`
  `colorSpace()`
  Returns ColorSpace, the range of colors.
  `int`
  `colorType()`
  Returns color type.
  `long`
  `computeByteSize(int rowBytes)`
  Returns storage required by pixel array, given ImageInfo dimensions, ColorType, and rowBytes.
  `long`
  `computeMinByteSize()`
  `boolean`
  `equals(Object o)`
  `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.
  `ImageInfo`
  `makeAlphaType(int newAlphaType)`
  Creates ImageInfo with same ColorSpace, ColorType, width, and height, with AlphaType set to newAlphaType.
  `ImageInfo`
  `makeColorSpace(ColorSpace newColorSpace)`
  Creates ImageInfo with same ColorType, AlphaType, width, and height, with ColorSpace set to newColorSpace.
  `ImageInfo`
  `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.
  `ImageInfo`
  `makeWH(int newWidth, int newHeight)`
  Creates ImageInfo with the same ColorType and AlphaType, with dimensions set to width and height.
  `int`
  `minRowBytes()`
  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.
  `String`
  `toString()`
  `int`
  `width()`
  Returns pixel count in each row.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ImageInfo

    public ImageInfo()
    Creates an empty ImageInfo with `ColorInfo.CT_UNKNOWN`, `ColorInfo.AT_UNKNOWN`, and a width and height of zero.

  - ### ImageInfo

    public ImageInfo(@Size(min=0L) int width, @Size(min=0L) int height)
    Creates ImageInfo from integral dimensions width and height, `ColorInfo.CT_UNKNOWN` and `ColorInfo.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 greater
      `height` - pixel row count; must be zero or greater

  - ### ImageInfo

    public ImageInfo(@Size(min=0L) int width, @Size(min=0L) int height, int colorType, int alphaType)
    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 greater
      `height` - 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 greater
      `h` - 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 greater
      `height` - pixel row count; must be zero or greater
      `cs` - range of colors; may be null

  - ### makeUnknown

    @Nonnull public static ImageInfo makeUnknown(@Size(min=0L) int width, @Size(min=0L) int height)
    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 greater
      `height` - 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

    @Nullable public ColorSpace 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 is `ColorInfo.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

    @Nonnull public ImageInfo makeWH(int newWidth, int newHeight)
    Creates ImageInfo with the same ColorType and AlphaType, with dimensions set to width and height.
    Parameters:
      `newWidth` - pixel column count; must be zero or greater
      `newHeight` - pixel row count; must be zero or greater
    Returns:
      created ImageInfo

  - ### makeAlphaType

    @Nonnull public ImageInfo makeAlphaType(int newAlphaType)
    Creates ImageInfo with same ColorSpace, ColorType, width, and height, with AlphaType set to newAlphaType.
    Returns:
      created ImageInfo

  - ### makeColorType

    @Nonnull public ImageInfo makeColorType(int newColorType)
    Creates ImageInfo with same ColorSpace, AlphaType, width, and height, with ColorType set to newColorType.
    Returns:
      created ImageInfo

  - ### makeColorSpace

    @Nonnull public ImageInfo makeColorSpace(@Nullable ColorSpace newColorSpace)
    Creates ImageInfo with same ColorType, AlphaType, width, and height, with ColorSpace set to newColorSpace.
    Returns:
      created ImageInfo

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`