Documentation
¶
Overview ¶
AImageDecoder API overview.
Documents the Android AImageDecoder pipeline provided by the ndk/image package. AImageDecoder (introduced in API 30) decodes JPEG, PNG, GIF, WebP, BMP, and ICO images into raw pixel buffers without requiring the Java Bitmap machinery.
Decoder lifecycle:
- Create -- from a file descriptor or in-memory buffer
- Inspect -- query header info (width, height, MIME type)
- Configure (optional) -- set target size for downscaling
- Stride -- call MinimumStride to learn the row byte count
- Allocate -- create a pixel buffer of stride * height bytes
- Decode -- fill the buffer with decoded pixel data
- Close -- release the decoder
The Decoder cannot be created directly from Go: it requires either a POSIX file descriptor (AImageDecoder_createFromFd) or an in-memory buffer (AImageDecoder_createFromBuffer). These factory functions are not yet exposed in the high-level image package; they can be accessed through the raw NDK layer when needed.
Creation pattern (pseudocode):
var decoder *image.Decoder fd := openImageFile() // POSIX file descriptor // create decoder from fd (factory not yet in high-level API) defer decoder.Close()
Once the Decoder is obtained, the high-level API takes over.
This program must run on an Android device with API 30+.