Package icyllis.arc3d.core

# Class Pixels

java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.core.Pixels

All Implemented Interfaces:
  `RefCounted`

public class Pixels extends RefCnt
This class is the smart container for pixel memory.
This class may be shared/accessed between multiple threads.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final long`
  `mAddress`
  `protected final Object`
  `mBase`
  `protected final LongConsumer`
  `mFreeFn`
  `protected final int`
  `mHeight`
  `protected boolean`
  `mImmutable`
  `protected final int`
  `mRowBytes`
  `protected final int`
  `mWidth`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Pixels(int width, int height, Object base, long address, int rowBytes, LongConsumer freeFn)`
  Creates `Pixels` from width, height.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `deallocate()`
  Override this method to invoke de-allocation of the underlying resource.
  `long`
  `getAddress()`
  The address if native buffer, or array base offset; may be NULL.
  `Object`
  `getBase()`
  The array if heap buffer; may be null.
  `int`
  `getHeight()`
  `int`
  `getRowBytes()`
  The size, in bytes, between the start of one pixel row/scanline and the next in buffer, including any unused padding between them.
  `int`
  `getWidth()`
  `boolean`
  `isImmutable()`
  Returns true if this container is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the container.
  `void`
  `setImmutable()`
  Marks this container is immutable, meaning that the contents of its pixels will not change for the lifetime of the container.
  `String`
  `toString()`

  ### Methods inherited from class icyllis.arc3d.core.RefCnt

  `create, create, getRefCnt, getRefCntAcquire, getRefCntVolatile, move, move, ref, unique, unref`

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

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

- ## Field Details

  - ### mWidth

    protected final int mWidth

  - ### mHeight

    protected final int mHeight

  - ### mBase

    protected final Object mBase

  - ### mAddress

    protected final long mAddress

  - ### mRowBytes

    protected final int mRowBytes

  - ### mFreeFn

    protected final LongConsumer mFreeFn

  - ### mImmutable

    protected boolean mImmutable

- ## Constructor Details

  - ### Pixels

    public Pixels(int width, int height, @Nullable Object base, long address, int rowBytes, @Nullable LongConsumer freeFn)
    Creates `Pixels` from width, height. rowBytes should be width times bpp, or larger. freeFn is used to free the address.
    Parameters:
      `base` - array if heap buffer; may be null
      `address` - address if native buffer, or array base offset; may be NULL
      `rowBytes` - size of one row of buffer; width times bpp, or larger
      `freeFn` - free function for native buffer; may be null

- ## Method Details

  - ### deallocate

    protected void deallocate()
    Description copied from class: `RefCnt`
    Override this method to invoke de-allocation of the underlying resource.
    Specified by:
      `deallocate` in class `RefCnt`

  - ### getWidth

    public int getWidth()

  - ### getHeight

    public int getHeight()

  - ### getBase

    @Nullable public Object getBase()
    The array if heap buffer; may be null.

  - ### getAddress

    public long getAddress()
    The address if native buffer, or array base offset; may be NULL.

  - ### getRowBytes

    public int getRowBytes()
    The size, in bytes, between the start of one pixel row/scanline and the next in buffer, including any unused padding between them. This value must be at least the width multiplied by the bytes-per-pixel, where the bytes-per-pixel depends on the color type.

  - ### isImmutable

    public boolean isImmutable()
    Returns true if this container is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the container.

  - ### setImmutable

    public void setImmutable()
    Marks this container is immutable, meaning that the contents of its pixels will not change for the lifetime of the container. This state can be set on a container, but it cannot be cleared once it is set.

  - ### toString

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