Package org.ngengine.stbimage
Class PngDecoder
java.lang.Object
org.ngengine.stbimage.PngDecoder
- All Implemented Interfaces:
StbDecoder
PNG decoder with zlib decompression.
Supports 1/2/4/8/16-bit depths, all color types (grayscale, RGB, RGBA, palette).
-
Constructor Summary
ConstructorsConstructorDescriptionPngDecoder(ByteBuffer buffer, IntFunction<ByteBuffer> allocator, boolean flipVertically) Creates a PNG 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 booleanisPng(ByteBuffer buffer) Tests whether the buffer starts with a PNG signature.load(int desiredChannels) Decodes image pixels.voidsetConvertIphonePngToRgb(boolean convertIphonePngToRgb) Enables/disables iPhone CgBI BGR(A)-to-RGB(A) conversion.voidsetUnpremultiplyOnLoad(boolean unpremultiplyOnLoad) Enables/disables iPhone PNG unpremultiply by alpha.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
-
PngDecoder
Creates a PNG decoder instance.- Parameters:
buffer- source dataallocator- output allocatorflipVertically- true to flip decoded rows
-
-
Method Details
-
isPng
Tests whether the buffer starts with a PNG signature.- Parameters:
buffer- source bytes- Returns:
- true if signature matches PNG
-
setConvertIphonePngToRgb
public void setConvertIphonePngToRgb(boolean convertIphonePngToRgb) Enables/disables iPhone CgBI BGR(A)-to-RGB(A) conversion.- Parameters:
convertIphonePngToRgb- true to convert channels
-
setUnpremultiplyOnLoad
public void setUnpremultiplyOnLoad(boolean unpremultiplyOnLoad) Enables/disables iPhone PNG unpremultiply by alpha.- Parameters:
unpremultiplyOnLoad- true to unpremultiply on decode
-
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
-