Package org.ngengine.stbimage
Class StbImageResult
java.lang.Object
org.ngengine.stbimage.StbImageResult
Result of an image decode operation.
Contains the decoded pixel data and metadata.
-
Constructor Summary
ConstructorsConstructorDescriptionStbImageResult(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 TypeMethodDescriptionintGets the bytes per channel (1 for 8-bit, 2 for 16-bit, 4 for float/HDR).intReturns the effective channel count ingetData().getData()Gets the raw pixel data as a ByteBuffer.intGets the total size of the pixel data in bytes.intReturns zero-based frame index for animated formats.intReturns image height in pixels.Number[]getPixel(int x, int y) Gets a pixel at the specified coordinates.intReturns the channel count requested by the caller.intgetWidth()Returns image width in pixels.booleanis16Bit()Indicates 16-bit channel storage.booleanisHdr()Indicates floating-point HDR storage.
-
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 datawidth- image widthheight- image heightchannels- output channel countrequestedChannels- originally requested channel countis16Bit- true when data uses unsigned 16-bit channelsisHdr- 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 datawidth- image widthheight- image heightchannels- output channel countrequestedChannels- originally requested channel countis16Bit- true when data uses unsigned 16-bit channelsisHdr- true when data uses float channelsframeIndex- frame index for animated decodes (0 for still images)
-
-
Method Details
-
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 ingetData().- 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
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).
-