Package-level declarations
Types
An auxiliary image of the primary image of a HEIC or AVIF file (#154): an image item that an auxl reference ties to the primary image, of the kind its auxC property names. ImageKodec.auxiliaryImages lists them and ImageKodec.decodeAuxiliaryImage decodes one.
The settings of a BMP encode (#184), for ImageKodec.encodeBmp. The defaults give the bytes the call without options gives.
How ImageKodec.encodeCcitt writes fax data. The parameters are the ones PDF's CCITTFaxDecode filter and io.github.yuroyami.imagekodec.codec.CcittFax.decode take, with PDF's defaults except for k, so a reader given the same values reads the data back.
What a file declares about the color space of its samples, as it declares it: ImageInfo.colorProfile reports it, and a decode with ColorTarget.Srgb or ImageKodec.convertToSrgb converts through it. Nearly every image is sRGB and says so or says nothing; the rest, such as a Display P3 photo or an Adobe RGB scan, draw with the wrong colors unless they are converted.
Where a decode leaves the colours of its samples, as Android's ImageDecoder.setTargetColorSpace sets it.
Marks the interface through which a module adds the codec of a HEIF item type. It may still change between releases, so a caller opts in to use it.
The gain map of an Ultra HDR JPEG (#130): a second, small JPEG after the main image that tells an HDR screen how much brighter each area of the photo may be drawn. ImageKodec.readMetadata finds it through the Multi-Picture Format segment of the main image, and an encodeJpeg with the metadata writes it again after the new main image, with an MPF segment that points to it.
The gain map metadata of ISO 21496-1, as the payload of a tmap item holds it (GainMapMetadata, read as libavif's avifParseToneMappedImageBox reads it). Each fraction of the payload is given as its numerator divided by its denominator; raw keeps the payload as stored.
The codec of one coded item type of HEIF (ISO/IEC 23008-12), such as hvc1 for HEVC. The core reads the container: it finds the items, joins grids, applies alpha, crops, turns and converts to RGB. A codec only turns the coded data of one item, or of one sample of a track, into planes.
What a codec reads from the configuration and the coded data of an item.
Decodes the coded samples of one item or one track.
One coded picture: configuration is the payload of the encoder's configuration property, without its box header, and data the coded data of the item. The picture decodes to width by height, the size of the planes. brand is the brand of ISO/IEC 23008-12 Annex B, or of the codec's own HEIF specification, that the coded picture conforms to, such as heic, heix or avif, for the ftyp box.
One coded sample of an image sequence: its data, the index from 0 in display order of the picture it codes, and whether it is a sync sample, decodable without the samples before it. A sequence's first sample is one.
The settings of a HEIF encode (#174), for ImageKodec.encodeHeic, ImageKodec.encodeHeic16, ImageKodec.encodeAvif and ImageKodec.encodeAvif16 (#176). Every parameter has a default, so name only the ones to change:
What a HeifEncoder makes of one picture. quality runs from 0 to 100, higher better, and is ignored when lossless asks for the planes to decode exactly as given. effort runs from 1 (fast) to 3 (thorough). The colour fields are the code points of ITU-T H.273 for the codec to signal in its own headers, or null to signal none, as for an alpha plane; HeifPlanes.fullRange gives the range.
The encoder of one coded item type of HEIF, such as hvc1 for HEVC (#174). The core writes the container: it converts RGB to planes, cuts a large picture into the tiles of a grid, and writes the items, their properties and their references. An encoder only turns the planes of one picture into the payload of its configuration property and the coded data of its item.
The HDR gain map of a HEIC or AVIF file (#153), as ImageKodec.decodeGainMap returns it: the decoded map and what the file says of it. It is returned, not applied. GainMap stays the gain map of an Ultra HDR JPEG, which holds JPEG bytes; this one holds decoded samples.
The decoded planes of one picture: luma width by height, then chroma subsampled by subX and subY (each 0 or 1), or luma alone when planes holds one plane. Each plane's rows are strides samples apart. Samples are unsigned in the low bitDepthLuma or bitDepthChroma bits of each Short. fullRange is false for the limited range of studio video.
The encoder of one image sequence (#177), which a HeifEncoder opens. The core hands it the pictures of the track in display order and writes the samples it returns into the track in the order they come, which is decoding order: an encoder that reorders pictures, as HEVC does with B pictures, holds a picture back and returns it later, each sample naming the picture it codes by HeifCodedSample.frameIndex. The core then writes the composition offsets (ctts) that put each picture back at its display time.
Thrown when input claims to be an image but can't be decoded: truncated data, corrupt structures, failed checksums, dimension overflow, or no recognisable format at all.
Image container formats ImageKodec can identify from magic bytes. Sniffing intentionally recognises more formats than ImageKodec.decode currently handles: "that's a WebP we can't decode yet" is a far better error than "unknown format".
What a file says about itself, read from its header alone: no pixel decode, no multi-megabyte allocation. This is what you want for laying out a grid before the images arrive, rejecting an upload that's 20000 px wide, or deciding whether a decoder should claim a file at all.
The ImageKodec facade. Everything is pure computation on byte arrays: no I/O and no platform types, so it behaves identically on every KMP target. It starts no threads of its own; a caller can hand the tiles of a grid image to its own threads through setTileRunner.
The metadata of a photo that a re-encode can carry over (#129): the exif block, the xmp packet and the icc colour profile. ImageKodec.readMetadata reads them from every format that carries them, and the encoders that take an ImageMetadata write what their format has a place for (#186), so a re-encoded camera photo keeps its capture date, its place, its camera and its colours. A GIF keeps no EXIF, and a BMP only the profile.
How ImageKodec.encodeJbig2 writes a page. Every choice is lossless: it changes the size and the time, never the pixels.
How ImageKodec.encodeJp2 writes a JPEG 2000 file (#180). Every parameter has a default, so name only those to change. The defaults write a lossy JP2 file at quality 75: the 9/7 wavelet over five resolution levels, one tile, code-blocks of 64 by 64, one quality layer in Jp2Progression.LRCP order.
The order in which a JPEG 2000 codestream lays out its packets (T.800 B.12.1): by quality layer, resolution, component and precinct, in the order of the letters. LRCP gives a file that sharpens as it loads, RLCP and RPCL one that grows in size, PCRL one that fills in by area, and CPRL one component after another.
The samples of a JPEG as the file stores them: every component after the inverse DCT and the upsampling, before any color conversion. ImageKodec.decodeJpegComponents returns it.
How ImageKodec.encodeJpeg and ImageKodec.encodeJpeg16 write a JPEG (#183): the process of ITU-T T.81, the entropy coding, the components and their sampling. Every parameter has a default, and the defaults write what ImageKodec.encodeJpeg writes from a quality alone: an 8-bit baseline file with the example Huffman tables of T.81 Annex K. The one change is grayscale, which by default writes a gray picture as one component.
Which encoder ImageKodec.encodeJpeg uses.
Whether ImageKodec.encodeJpeg writes one component, the gray level, or three.
The chroma subsampling of a JPEG that ImageKodec.encodeJpeg writes in YCbCr.
A JP2 colour specification box (T.800, I.5.3.3), as JpxComponents.colorSpecification reports it.
The samples of a JPEG 2000 image as the codestream stores them: every component after the inverse wavelet, the multiple component transform and the DC level shift, sampled onto the image grid, and before the JP2 palette, channel definitions and colour space. ImageKodec.decodeJpxComponents returns it.
How ImageKodec.encodeJxl writes a JPEG XL file (#179).
The settings of a JPEG XR encode (#181), for ImageKodec.encodeJxr, ImageKodec.encodeJxr16 and ImageKodec.encodeJxrCmyk.
A decoded animation: GIF, APNG, animated WebP, animated AVIF and animated JPEG XL all arrive in this shape. Static images decode as a single frame, so ImageKodec.decodeAnimation is total over every supported format.
A decoded raster image: width × height pixels, packed as non-premultiplied ARGB_8888 in a row-major argb array (argb[y * width + x], alpha in the top byte). One layout for every source format: decoders normalise grayscale, palette, BGR and 16-bit inputs into this on the way out, so consumers and the Compose interop never branch on the source format.
A decoded image at 16 bits a sample, for the files whose low byte matters: depth maps, scientific and medical images, heavily graded photographs. KiteBitmap keeps 8 bits a channel and is what drawing wants; this keeps every bit a 16-bit PNG or TIFF stores, and ImageKodec.decode16 is where it comes from.
One presented frame of an animation: the fully composited canvas (disposal methods, transparency overlay and frame offsets already applied), plus its display duration.
Where the video of a Motion Photo sits in its file (#131): videoOffset bytes from the start, videoLength bytes long. format says how the file named it.
How a decoded image relates to the scene it was captured from: the EXIF Orientation tag (TIFF tag 274), which phone cameras write instead of physically rotating pixels. A portrait photo is usually stored landscape with Rotate90 set, so anything that draws raw decoded pixels shows it sideways.
The colour type a PNG is written in (PNG, Third Edition, 6.1), for PngEncodeOptions.
How ImageKodec.encodePng writes a PNG (#182). Every choice is lossless: the file decodes to exactly the pixels it was given, so a colorType or bitDepth that cannot hold the image makes the encode throw rather than change a pixel.
How a colour outside the target's gamut, or a source white that is not the target's, is mapped (ICC.1 Annex D). Perceptual and saturation use the profile's own tables when it has them; a matrix profile maps them as relative colorimetric, with black point compensation as lcms2 applies it. Absolute colorimetric keeps the source's media white instead of adapting it.
How ImageKodec.encodeTiff compresses each strip or tile (TIFF 6.0 Compression, tag 259).
The settings of a TIFF encode (#184), for ImageKodec.encodeTiff, ImageKodec.encodeTiff16 and ImageKodec.encodeTiffCmyk. The defaults give the bytes the calls without options give.
The kind of samples ImageKodec.encodeTiff writes (TIFF 6.0 PhotometricInterpretation, tag 262).
One job of a TileRunner: the decode of one tile. It never throws.
Runs the independent jobs of a decode, the tiles of a HEIC or AVIF grid, on the threads it chooses (#152), and the tiles of a grid that encodeHeic codes (#174). ImageKodec.setTileRunner sets the one runner that every decode uses; the default, Serial, runs the jobs in order on the calling thread.
The input is a well-formed image in a format, or a format feature, ImageKodec doesn't decode: an AVIF of SMPTE ST 2085 colour, a JPEG XR of N channels. The message always names the specific feature, and ImageKodec.probe reports the same thing up front through ImageInfo.unsupportedReason, so a caller can route the file elsewhere instead of catching this.
The prediction filter of a lossy WebP's alpha plane (the ALPH chunk's filtering method).
How ImageKodec.encodeWebp writes a WebP (#178).
Functions
cropped applied to every frame, preserving delays and loop count.
Downscale every frame to exactly targetWidth×targetHeight with KiteBitmap.downscaledTo, preserving delays and the play count. Equal canvas dimensions return this instance.
Downscale to exactly targetWidth×targetHeight with scaled's alpha-weighted box filter. The caller chooses the aspect ratio; this operation does not fit the requested dimensions inside another box. Equal dimensions return this instance.
flippedHorizontal applied to every frame.
Mirror left-to-right.
flippedVertical applied to every frame.
Mirror top-to-bottom.
oriented applied to every frame, preserving delays and loop count.
Apply an EXIF orientation so the result is oriented the way the camera meant it to be seen. Orientation.Normal returns the same instance.
rotated180 applied to every frame.
Rotate a half turn. Dimensions are unchanged.
rotated270 applied to every frame.
Rotate a quarter turn counter-clockwise. Width and height swap.
rotated90 applied to every frame.
Rotate a quarter turn clockwise. Width and height swap.
Downscale every frame of an animation to fit inside maxWidth×maxHeight (same box filter and aspect handling as KiteBitmap.scaled), preserving delays and the loop count. This is where animated memory goes: a full-screen GIF shown as an avatar keeps W×H×4 bytes per frame unless scaled down.
Downscale to fit inside maxWidth×maxHeight, preserving aspect ratio, using box (area-average) filtering: each destination pixel averages the source pixels under it, each weighted by the part of it that lies in the bin, so a thin line keeps the same contrast wherever it falls and thumbnails don't shimmer the way nearest-neighbor ones do.
transposed applied to every frame.
Mirror across the main diagonal: dst(x, y) = src(y, x). Axes swap.
transversed applied to every frame.
Mirror across the anti-diagonal. Axes swap.