Class StbImageResult

java.lang.Object
org.ngengine.stbimage.StbImageResult

public class StbImageResult extends Object
Result of an image decode operation. Contains the decoded pixel data and metadata.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StbImageResult(ByteBuffer data, int width, int height, int channels, int requestedChannels, boolean is16Bit, boolean isHdr)
    Creates a decoded image payload container.
    StbImageResult(ByteBuffer data, int width, int height, int channels, int requestedChannels, boolean is16Bit, boolean isHdr, int frameIndex)
    Creates a decoded image payload container.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the bytes per channel (1 for 8-bit, 2 for 16-bit, 4 for float/HDR).
    int
    Returns the effective channel count in getData().
    Gets the raw pixel data as a ByteBuffer.
    int
    Gets the total size of the pixel data in bytes.
    int
    Returns zero-based frame index for animated formats.
    int
    Returns image height in pixels.
    getPixel(int x, int y)
    Gets a pixel at the specified coordinates.
    int
    Returns the channel count requested by the caller.
    int
    Returns image width in pixels.
    boolean
    Indicates 16-bit channel storage.
    boolean
    Indicates floating-point HDR storage.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StbImageResult

      public StbImageResult(ByteBuffer data, int width, int height, int channels, int requestedChannels, boolean is16Bit, boolean isHdr)
      Creates a decoded image payload container.
      Parameters:
      data - raw interleaved pixel data
      width - image width
      height - image height
      channels - output channel count
      requestedChannels - originally requested channel count
      is16Bit - true when data uses unsigned 16-bit channels
      isHdr - true when data uses float channels
    • StbImageResult

      public StbImageResult(ByteBuffer data, int width, int height, int channels, int requestedChannels, boolean is16Bit, boolean isHdr, int frameIndex)
      Creates a decoded image payload container.
      Parameters:
      data - raw interleaved pixel data
      width - image width
      height - image height
      channels - output channel count
      requestedChannels - originally requested channel count
      is16Bit - true when data uses unsigned 16-bit channels
      isHdr - true when data uses float channels
      frameIndex - frame index for animated decodes (0 for still images)
  • Method Details

    • getData

      public ByteBuffer getData()
      Gets the raw pixel data as a ByteBuffer. For 8-bit images: each channel is 1 byte. For 16-bit images: each channel is 2 bytes (big-endian). For HDR images: each channel is 4 bytes (float). Pixel format is interleaved: R, G, B, A, R, G, B, A... Rows are stored top-to-bottom (not flipped).
    • getWidth

      public int getWidth()
      Returns image width in pixels.
      Returns:
      width
    • getHeight

      public int getHeight()
      Returns image height in pixels.
      Returns:
      height
    • getChannels

      public int getChannels()
      Returns the effective channel count in getData().
      Returns:
      channel count
    • getRequestedChannels

      public int getRequestedChannels()
      Returns the channel count requested by the caller.
      Returns:
      requested channel count
    • is16Bit

      public boolean is16Bit()
      Indicates 16-bit channel storage.
      Returns:
      true for 16-bit output
    • isHdr

      public boolean isHdr()
      Indicates floating-point HDR storage.
      Returns:
      true for HDR float output
    • getFrameIndex

      public int getFrameIndex()
      Returns zero-based frame index for animated formats.
      Returns:
      frame index, 0 for still images
    • getBytesPerChannel

      public int getBytesPerChannel()
      Gets the bytes per channel (1 for 8-bit, 2 for 16-bit, 4 for float/HDR).
    • getDataSize

      public int getDataSize()
      Gets the total size of the pixel data in bytes.
    • getPixel

      public Number[] getPixel(int x, int y)
      Gets a pixel at the specified coordinates. The returned array contains channel values. For HDR, values are floats; otherwise, they're ints (0-255 or 0-65535).