KitePageRasterizer

class KitePageRasterizer(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer, maxBitmapPixels: Long)

Imperative page → ImageBitmap pipeline. This is the raster engine behind KiteDocView; it is public so apps with custom viewers (own pagers, thumbnail grids, PNG export jobs) don't have to re-implement the CTM/flip/hairline math themselves.

Obtain one inside composition with rememberKitePageRasterizer, or construct it directly off-composition when you already hold a TextMeasurer.

rasterize runs synchronously on the calling thread; rasterizeOffMain moves the work to kitepdfRasterDispatcher (a background pool on JVM/Android/Apple, Main on JS/Wasm) so a complex page never janks scrolling or pinch. KiteDocView uses that path.

Constructors

Link copied to clipboard
constructor(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer, maxBitmapPixels: Long)
constructor(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer)

Binary-compatible constructor using the default bitmap ceiling.

Functions

Link copied to clipboard
fun rasterize(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null): ImageBitmap

Renders page into a fresh widthPx×heightPx bitmap.

fun rasterize(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null, canvasDecorator: KiteCanvasDecorator?): ImageBitmap

rasterize with an application canvas wrapper. See KiteCanvasDecorator for ordering, repeatable paint passes and threading requirements.

Link copied to clipboard
suspend fun rasterizeOffMain(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null): ImageBitmap

rasterize, off the main thread where the platform allows. One page runs to completion once started (the synchronous renderer has no cancellation points; the operation budget bounds the worst case), so cancellation takes effect between pages.

suspend fun rasterizeOffMain(page: KitePage, widthPx: Int, heightPx: Int, background: Color = Color.White, hairlineWidthPx: Float = 1.0f, theme: ReaderTheme? = null, canvasDecorator: KiteCanvasDecorator?): ImageBitmap

rasterizeOffMain with an application canvas wrapper. See KiteCanvasDecorator for ordering, repeatable paint passes and threading requirements.