overview

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 2 Imported by: 0

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:

  1. Create -- from a file descriptor or in-memory buffer
  2. Inspect -- query header info (width, height, MIME type)
  3. Configure (optional) -- set target size for downscaling
  4. Stride -- call MinimumStride to learn the row byte count
  5. Allocate -- create a pixel buffer of stride * height bytes
  6. Decode -- fill the buffer with decoded pixel data
  7. 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+.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL