KiteImageData

One image a document handler produced, ready for a KiteCanvas: the samples plus everything needed to read them (colour space, bit depth, /Decode, masks). PDF fills it from a /XObject /Image resource entry (ISO 32000-1 §8.9.5); EPUB fills it from a decoded PNG, JPEG or GIF.

The decoded byte buffer's interpretation depends on the filter chain:

  • DCTDecode → JPEG file in encodedBytes; decoded by the host platform's image loader (see ImageDecoder in :kitepdf-compose-viewer).

  • FlateDecode / LZWDecode / CCITTFaxDecode / ASCII / RunLength → pixel samples already decoded into pixelBytes; toRgbaBytes assembles RGBA using resolvedColorSpace, bitsPerComponent, and decode.

  • JBIG2Decode → decoded in pure Kotlin (Jbig2Decoder, the generic-region arithmetic path) into a 1-bpc DeviceGray RAW image; unsupported JBIG2 flavours fall back to Kind.JBIG2 with the payload in encodedBytes.

  • JPXDecode (JPEG 2000) → decoded in pure Kotlin (JpxDecoder, part 1 baseline) into an 8-bpc RAW image; unsupported flavours fall back to Kind.JPEG2000 with the payload in encodedBytes.

Callers should switch on kind to pick the right rendering path. Stencil masks (/ImageMask true) carry isImageMask and are tinted by maskFill.

Transparency reaches the raster path in three forms: /SMask and a stencil /Mask both arrive as softMaskAlpha, and a colour-key /Mask arrives as colorKeyMask. /SMask wins when an image carries both.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard

Colour-key /Mask ranges (ISO 32000-1 §8.9.6): 2 × n integers, a min and a max per colour component, in the image's SOURCE sample values (before /Decode and colour conversion). A pixel whose every component falls inside its range is fully transparent. Null unless the image carries an array-valued /Mask and no /SMask.

Link copied to clipboard
Link copied to clipboard

/Decode array (per-component min/max remap), or null for the identity map.

Link copied to clipboard

Encoded bytes, for kinds that defer decoding to a platform image loader.

Link copied to clipboard
val height: Int
Link copied to clipboard

The /Interpolate entry of ISO 32000-1, Table 89: the image asks to stay smooth when enlarged (see imageSampling). Images from EPUB, SVG, XPS and CBZ files set it, because browsers smooth an enlarged image by default.

Link copied to clipboard

True for /ImageMask stencils: 1-bpc, painted with maskFill.

Link copied to clipboard
Link copied to clipboard

Fill colour to tint an isImageMask stencil (the graphics-state fill colour).

Link copied to clipboard

Pixel bytes, populated for Kind.RAW (already run through the filter chain).

Link copied to clipboard

The image's colour space resolved against the document (Indexed palettes, ICCBased component counts, etc.). Null for stencil masks and when it could not be resolved (then toRgbaBytes infers a device space from the data).

Link copied to clipboard

Soft-mask alpha (ISO 32000-1 §11.6.5.2), normalised to 8-bit grayscale: one byte per pixel, 0 = transparent, 255 = opaque, row-major over softMaskWidth×softMaskHeight. Null when the image carries neither a /SMask nor a stencil /Mask.

Link copied to clipboard
Link copied to clipboard

The /Matte colour of the /SMask, converted to RGB. When it is set, the colour samples were preblended with it (ISO 32000-1, 11.6.5.3), and toRgbaBytes undoes that blend. Null when the soft mask has no /Matte.

Link copied to clipboard
Link copied to clipboard
val width: Int

Functions

Link copied to clipboard

Assemble a Kind.RAW image's already-decoded samples into a flat RGBA8888 buffer (R,G,B,A per pixel, row-major, no padding) that a platform backend can wrap in a bitmap.