Class StbImage

java.lang.Object
org.ngengine.stbimage.StbImage

public class StbImage extends Object
Pure Java implementation of stb_image.h
  • Constructor Details

  • Method Details

    • registerDecoder

      public void registerDecoder(String format, StbImage.StbDecoderInstancer instancer, Predicate<ByteBuffer> formatChecker)
      Registers a decoder type and its format probe.
      Parameters:
      format - format name of the decoder
      instancer - decoder class with constructor (ByteBuffer, IntFunction, boolean)
      formatChecker - predicate that returns true when buffer matches decoder format
    • unregisterDecoder

      public void unregisterDecoder(String format)
      Unregisters a decoder previously added with registerDecoder(String, StbDecoderInstancer, Predicate).
      Parameters:
      format - format name of the decoder to remove
    • unregisterDecoder

      public void unregisterDecoder(StbImage.StbDecoderInstancer instancer)
      Unregisters a decoder by its instancer reference.
      Parameters:
      instancer - decoder class reference to remove
    • unregisterAllDecoders

      public void unregisterAllDecoders()
      Unregisters all decoders, leaving the instance with no supported formats.
    • getRegisteredFormats

      public List<String> getRegisteredFormats()
      Returns a list of registered decoder formats.
      Returns:
      list of format names
    • getDecoderCount

      public int getDecoderCount()
      Returns the number of registered decoders.
      Returns:
      decoder count
    • setConvertIphonePngToRgb

      public void setConvertIphonePngToRgb(boolean convertIphonePngToRgb)
      Enables/disables automatic iPhone PNG BGR->RGB conversion for CgBI PNGs.
      Parameters:
      convertIphonePngToRgb - true to convert CgBI channel order to RGB(A)
    • isConvertIphonePngToRgb

      public boolean isConvertIphonePngToRgb()
      Returns whether iPhone PNG channel conversion is enabled.
      Returns:
      true when CgBI PNGs are converted from BGR(A) to RGB(A)
    • setUnpremultiplyOnLoad

      public void setUnpremultiplyOnLoad(boolean unpremultiplyOnLoad)
      Enables/disables unpremultiply for iPhone PNG alpha data.
      Parameters:
      unpremultiplyOnLoad - true to unpremultiply by alpha during decode
    • isUnpremultiplyOnLoad

      public boolean isUnpremultiplyOnLoad()
      Returns whether iPhone PNG unpremultiply is enabled.
      Returns:
      true when unpremultiply is enabled
    • setFillGifFirstFrameBackground

      public void setFillGifFirstFrameBackground(boolean fillGifFirstFrameBackground)
      Enables/disables logical-screen background fill for untouched pixels on GIF first frame.

      True matches stb_image behavior. False keeps untouched pixels transparent.

      Parameters:
      fillGifFirstFrameBackground - true to match stb-style first-frame fill
    • isFillGifFirstFrameBackground

      public boolean isFillGifFirstFrameBackground()
      Returns whether GIF first-frame untouched pixels are filled from background color.
      Returns:
      true when stb-style first-frame background fill is enabled
    • getDecoder

      public StbDecoder getDecoder(ByteBuffer buffer, boolean flipVertically)
      Selects and instantiates a decoder for the provided buffer.
      Parameters:
      buffer - input image bytes
      flipVertically - true to vertically flip decoded output
      Returns:
      matching decoder instance