Class JpegDecoder

java.lang.Object
org.ngengine.stbimage.JpegDecoder
All Implemented Interfaces:
StbDecoder

public class JpegDecoder extends Object implements 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 Details

    • JpegDecoder

      public JpegDecoder(ByteBuffer src, IntFunction<ByteBuffer> allocator, boolean flipVertically)
      Creates a JPEG decoder instance.
      Parameters:
      src - source data
      allocator - output allocator
      flipVertically - true to vertically flip decoded output
  • Method Details

    • isJpeg

      public static boolean isJpeg(ByteBuffer buffer)
      Tests whether the input starts with JPEG SOI marker bytes.
      Parameters:
      buffer - source bytes
      Returns:
      true for JPEG signature
    • getAllocator

      public IntFunction<ByteBuffer> getAllocator()
      Returns the allocator used by this decoder for output buffers.
      Specified by:
      getAllocator in interface StbDecoder
      Returns:
      allocator function
    • info

      public StbImageInfo info()
      Reads image metadata without fully decoding pixel data.
      Specified by:
      info in interface StbDecoder
      Returns:
      image information
    • load

      public StbImageResult load(int desiredChannels)
      Decodes image pixels.
      Specified by:
      load in interface StbDecoder
      Parameters:
      desiredChannels - requested output channels (0 keeps source/default behavior)
      Returns:
      decoded image result