Package org.ngengine.stbimage
Class JpegDecoder
java.lang.Object
org.ngengine.stbimage.JpegDecoder
- All Implemented Interfaces:
StbDecoder
JPEG decoder - baseline (sequential) and progressive DCT decoder, implemented to match stb_image.h behavior closely.
Supported:
- Baseline (SOF0) and Extended Sequential (SOF1)
- Progressive (SOF2)
- CMYK (via APP14 marker)
Not supported:
- Arithmetic coding
Notes:
- Output matches stb_image's resampling + YCbCr conversion (including the hv_2 filter).
-
Constructor Summary
ConstructorsConstructorDescriptionJpegDecoder(ByteBuffer src, IntFunction<ByteBuffer> allocator, boolean flipVertically) Creates a JPEG decoder instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the allocator used by this decoder for output buffers.info()Reads image metadata without fully decoding pixel data.static booleanisJpeg(ByteBuffer buffer) Tests whether the input starts with JPEG SOI marker bytes.load(int desiredChannels) Decodes image pixels.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ngengine.stbimage.StbDecoder
load16, loadAllFrames, loadf, loadNextFrame
-
Constructor Details
-
JpegDecoder
Creates a JPEG decoder instance.- Parameters:
src- source dataallocator- output allocatorflipVertically- true to vertically flip decoded output
-
-
Method Details
-
isJpeg
Tests whether the input starts with JPEG SOI marker bytes.- Parameters:
buffer- source bytes- Returns:
- true for JPEG signature
-
getAllocator
Returns the allocator used by this decoder for output buffers.- Specified by:
getAllocatorin interfaceStbDecoder- Returns:
- allocator function
-
info
Reads image metadata without fully decoding pixel data.- Specified by:
infoin interfaceStbDecoder- Returns:
- image information
-
load
Decodes image pixels.- Specified by:
loadin interfaceStbDecoder- Parameters:
desiredChannels- requested output channels (0 keeps source/default behavior)- Returns:
- decoded image result
-