TakePicture

fun EventSchemaBuilderScope.TakePicture(id: String = randomId(), trigger: EventTrigger, compression: CompressionScheme? = null, resize: ImageResizeOptions? = null, outputType: TakePictureEventSchema.OutputType = pictureArrayOfBytes(), events: EventSchemaBuilderScope.() -> Unit = {})

Opens the camera and emits the captured photo downstream, on the IO dispatcher. When compression is set the bytes are re-encoded to WebP through byQuality/byTargetSize (the capture is treated as image/png), with resize applied in the same pass (the compressor's own defaults are used when resize is null); when compression is null the original bytes are emitted untouched and resize has no effect. Does not consume incomingData. Dispatches onSuccess (carrying the image, shaped by outputType) when a picture was taken and processed; onCancelled (no data) when the camera returns nothing, e.g. the user backs out of the capture; onFailure (carrying the thrown exception) when capturing or compressing throws.

Parameters

id

Unique identifier of this event. Defaults to a random id.

trigger

Trigger that fires this event, built via EventTriggers.

compression

Re-encoding applied to the captured image, built with byQuality or byTargetSize. Defaults to none (original bytes, resize has no effect).

resize

Resize applied alongside compression, built with imageResizeOptions; only takes effect when compression is non-null. Defaults to none (compressor's own defaults).

outputType

Shape of the image delivered as incomingData — pictureArrayOfBytes or pictureBase64. Defaults to raw bytes.

events

Child events chained after this one, wired to its triggers (onSuccess, onCancelled, onFailure).