EpubPageRasterizer

Headless raster output for an EpubPage using Skia (no Compose), the EPUB twin of PdfPageRasterizer. Both draw through the shared core KiteCanvas seam (SkiaCanvas), so one Skiko backend serves PDF and EPUB alike on every target (JVM, Android, iOS, macOS, Linux, JS/Wasm).

Typical use cases:

  • Reader-app page bitmaps (the Compose viewer rasterises through this)

  • Cover / thumbnail / preview generation

  • CI screenshot baselines for the EPUB engine

The result is an sRGB raster sized to the page in points multiplied by scale. Pass scale = 2.0 for retina / "2× density" output.

Functions

Link copied to clipboard
fun encodeToPng(page: EpubPage, scale: Double = 1.0, background: Int = Color.WHITE, theme: ReaderTheme? = null): ByteArray

Convenience: render and return PNG bytes.

Link copied to clipboard
fun renderToImage(page: EpubPage, scale: Double = 1.0, background: Int = Color.WHITE, theme: ReaderTheme? = null): Image

Render page into a freshly-allocated Skia Image. The caller owns the returned object and should call close() (or use encodeToPng) once done. Skia images hold off-heap memory.