media library

The hosting app's MediaHost, the media picker, the camera, the compose page, the image editors, the gallery transition, and the leaf widgets and models of the media flow.

Classes

AlbumsScreen
Pushed inside the picker's sheet via host?.push(...). Pops with the chosen XAlbum (or null on back). Mirrors telegram-iOS's MediaGroupsScreen pushed onto the modal's nav stack (MediaPickerScreen.swift:3427, MediaGroupsScreen.swift:152).
AnimatedToolChrome
Animates the tool's controls strip in / out: scales 0.1 → 1.0 and slides +30 logical px → 0 over the screen's transition. Mirrors telegram's animateOutToTool chrome scale (MediaEditorScreen.swift:677-704) run in reverse for the tool entering. The preview / canvas isn't wrapped — it stays put.
Animator<T>
Tween-driving animator with cancel-and-replace semantics.
AudioMedia
An audio recording or file.
BrushSizeSlider
Vertical 0–1 slider that floats on the left edge of the editor area.
BrushTypePicker
The row of brushes; the selected one stands taller, and the row fades out at its foot.
CameraButton
The shutter: a ring around a disc that is white for a photo, red for a video, and a small red square while recording.
CameraCell
The picker's rounded live preview and camera affordance.
CameraCellIcon
The cell affordance, fading away as its preview expands.
CameraCellSource
The mounted cell's bounds and its exclusive loan of the preview to a page.
CameraFit
Immutable (tx, ty, scale) triple — a uniform-scale + translate 2D affine, the only shape used for both the host viewport-fit camera and the draw screen's local pinch/pan camera. Implements +, -, * so Animator<CameraFit> can interpolate it element-wise.
CameraGuidelinePainter
Paints a corner bracket in each corner of the viewfinder.
CameraPage
The camera: takes a photo or records a video, and pops with it as an XMedia, or with nothing when closed.
CameraSession
Owns the controller and its replacements; borrowers listen without disposing.
CameraThumb
The live preview of controller over color, covering its box on mobile and contained on desktop, with child on top.
ChatSendResult
Per-result handle returned by ComposeSubmitCallback: the placeholder bubble's clientMessageId plus a closure that resolves the chat bubble's transition source for that cid. The closure resolves lazily against the chat's current widget tree, so it returns a live source on any frame after the placeholder has been built.
ComposeEntry
Per-asset view-model for the media compose pipeline. Owns the caption controller, viewer transform, video controller, the lazily decoded source image, the persistent editor layers (vector state, survives across tool re-entries), and a cached rendered preview.
ComposeEntryView
Stateless preview widget. For ImageMedia, paints the source (or renderedPreview if set) via the host camera matrix — the SAME matrix tool screens use — so transitioning compose → crop / draw is a continuous animation of one matrix, with no boundary jump. For VideoMedia, renders the player when initialised.
ComposePage
Folded single + multi compose page. Accepts a list of XMedia (1..N); single-asset callers wrap with [m]. The PageView is non-swipeable when N == 1 and the dot indicator hides for the same case — single-asset surface is identical to today, just without the swipe / dots.
ComposePlayOverlay
Telegram picker-parity playback gate over the compose video preview (TGMediaPickerGalleryVideoItemView): while paused, a centered half-black disc with the gallery's play triangle sits on the poster; tapping it plays. While playing the disc hides and a tap anywhere on the video pauses (TG's singleTap → pausePressed).
ComposeResult
One slide's worth of submit output. Per-entry caption + a reference to the picker's original media + (for edited entries) the in-memory composited ui.Image. The chat-side dispatcher (chat_page._sendComposeResults) feeds the composedImage into bloc.sendMediaMessage(OutgoingImageFromComposite(...)) so the message is inserted into the stream before the PNG encode + upload run — telegram's enqueueMessages(mediaReference:) parity.
CountOdometer
Per-digit "slot-reel" count display. Each digit column animates independently when its value changes; an AnimatedSize handles the row growing / shrinking when the digit count itself changes (e.g. 9 → 10). Right-aligned so the ones-place stays put while leading digits add or drop on the left.
CropAreaOverlay
Telegram's draggable crop-area handles (TGPhotoCropAreaView + TGPhotoCropControl): four 44pt corner controls centered ON the crop corners and four 44pt-thick edge strips between them, each with 16pt of extra hit slop except below crop.bottom, where the bottom edge and corners stop at kCropDialHandleReach so the dial owns the rest of the gutter. All hit-opaque (TG's exclusiveTouch — a drag that starts on a handle never reaches the pinch surface).
CropControls
Bottom control row for the crop tool: cancel / rotate-90 / flip / aspect-ratio / submit.
CropGestures
Pinch-to-zoom + drag-to-pan inside the crop rectangle. Scale and rotation anchor at the gesture's focal point: the image point under the fingers at gesture-start stays under them for the rest of the gesture (same anchoring as DrawGestures' viewer camera).
CropImageLayer
Crop / rotate / flip tool layer.
CroppedVideoPreview
Live compose preview of a cropped video: child (the player) is laid out at the entry's poster dimensions — the pixel space the crop geometry was authored on (not the controller-reported video size, which some decoders report pre-rotation; a crop implies the poster is decoded) — run through the same source→output affine the export bakes (VideoCropGeometry.transform) and clipped to the crop output rect, so preview and export show the identical crop. The clipped result is placed on screen by ComposeEntry.cropOutputCamera — the same placement the image preview paints with, so image and video crops center identically and ride the compose↔tool camera animation together.
CropRotationDial
The dial's gesture band: full viewport width, from crop.bottom down to the bottom of the editor body. Dragging it turns the image and re-covers the crop on every update, never zooming below CropImageLayer.rotationScaleFloor, so a drag out and back returns the zoom the user had. A double tap springs the rotation back to 0 through CropImageLayer.resetRotation.
CropRotationDialState
State of a CropRotationDial; tests read its counters.
CropScenePainter
Compose-aware viewport painter for the crop editor.
CropScreen
Pushed tool screen for the crop editor. Borrows a CropImageLayer from the host (e.g. ComposeEntry); on push the layer snapshots its state, on cancel it restores from the snapshot, on apply it commits (current state IS committed). Pops with true on apply / false on cancel. The host re-renders its preview from the committed layer state: an image's preview is the composite ComposeEntry.composedImage gives the submit, and a video's crop rides ComposeResult.videoEdit.
CropSnapshot
By-value snapshot of a CropImageLayer's mutable user-edit state. Captured at tool-open by CropImageLayer.saveSnapshot; consumed on cancel by CropImageLayer.restoreSnapshot. Camera is host-owned and not part of the snapshot — only fields user gestures actually mutate are rolled back.
DismissCarrier
Drag-to-dismiss carrier. Tracks vertical drag from rest; on release dismisses (when distance > viewport.h/4 or velocity > 1.0 px/ms) or snaps back (kGalleryCustomSpring).
DismissCarrierState
Public state — the shell forwards inner-zoom past-Y drags into here directly, bypassing the carrier's GestureDetector (which may be disabled via DismissCarrier.blocked).
DrawColorRow
The colour row: the rainbow swatch, the palette, the add button.
DrawControls
Bottom control strip for the draw tool. Three rows top → bottom: brush picker, color row (rainbow + 8 swatches + plus), action row (cancel circle + Draw/Text segmented + check circle).
DrawGestures
One- or two-finger gesture surface for the draw editor.
DrawImageLayer
Free-draw layer with four brush types (pen / marker / neon / eraser), per-brush thickness, velocity-aware width, and an optional arrow toggle on pen. Strokes operate in image-space; the gesture surface translates viewport coords via toImageSpace.
DrawScenePainter
Compose-aware viewport painter for the draw editor.
DrawScreen
Pushed tool screen for the draw editor. Borrows a DrawImageLayer and an optional EntityLayer from the host (e.g. ComposeEntry); on push they snapshot their state, on cancel they restore, on apply they commit. Pops true on apply / false on cancel.
DrawSnapshot
By-value snapshot of a DrawImageLayer's mutable state. Captured at tool-open by DrawImageLayer.saveSnapshot; consumed on cancel by DrawImageLayer.restoreSnapshot. The strokes list is a shallow copy — committed strokes are settled and don't mutate after the drying animator completes, so reference-sharing is safe. Per-brush color and thickness maps are deep-copied.
Editor
A staged image editor — a stack of Painter / Exporter layers plus optional gesture and overlay widgets, with a controls strip the host renders in place of its own command bar while editing.
EditorActionRow
Cancel · ModeSegmented pill · submit, shared by the draw and text strips.
EditorPainter
CustomPainter that delegates to all Painter layers in scene with the host camera threaded through. Repaint is driven by the editor itself (via super.repaint: scene) plus the camera if supplied.
EntityGestures
Selection + manipulation surface for layer, stacked as a sibling above DrawGestures.
EntityLayer
Overlay-entity layer: TextEntity instances in source-image space.
EntitySelectionPainter
Selection chrome: the selected entity's frame and its two side handles.
EntitySnapshot
By-value snapshot of an EntityLayer's mutable state. Captured at tool-open by EntityLayer.saveSnapshot, consumed on cancel by EntityLayer.restoreSnapshot.
FileMedia
A file of any other kind.
FlashButton
A bolt in a circle that fills amber when on, struck through when off.
FlashPainter
Paints the strike-through of the flash button, shrinking to nothing as t reaches 1.
GallerySource
A registration that lets the gallery query a chat-side widget for its current on-screen rect and a fresh snapshot. Re-queried at open AND close time so chat scrolling between events is handled correctly.
GalleryTransition
A snapshot flight whose shell keeps its element identity across phases.
HiddenMedia
Paint-time source ownership, including the route-removal frame.
HiddenMediaController
Coordinates "which chat bubble is currently being shown by a gallery and should hide its image." Maintains a stack of HideSlots so overlapping gallery screens (A's close-anim still running while B is pushed) don't clobber each other: A's release pops only A's slot, leaving B's bubble hidden until B itself releases.
HideSlot
Opaque handle returned by HiddenMediaController.acquire. Identity-based.
ImageMedia
A still image.
MediaColors
The colours the media flow paints with.
MediaCommandsBar
Compose-page editor entry-points: crop, draw, aspect-ratio. The host (e.g. ComposePage) replaces this bar with the active editor's own controls strip while a tool is mounted. A tool without a callback shows dimmed and takes no press.
MediaFlightChrome
Background or controls that fade in place with route progress.
MediaFlightSurface
Current media pixels, separated from stationary background and controls.
MediaHost
What the media flow reads from the app that hosts it. The app sets MediaHost.current before it shows any of the flow.
MediaIcons
The icons the media flow draws that have no Cupertino equivalent in use.
MediaInsets
Safe-area and keyboard insets taken from the binding rather than from MediaQuery, which a router may strip the keyboard's inset out of. It notifies when either changes.
MediaPickerPage
A media-library sheet with a live camera cell and maxSelection picks.
MediaStrings
The strings the media flow shows.
MediaText
The text styles the media flow sets type in.
MicPermissionBanner
Compact pill shown above the camera shutter when the user is in video mode but mic permission isn't (yet) granted. Tapping routes through XCameraController.requestAudioPermission — the native side shows the in-app system prompt when the OS will, and deep-links to Settings on permanent denial. The page is responsible for re-polling permission on AppLifecycleState.resumed.
ModeSegmented
"Draw / Text" pill. mode's segment is the filled one. Tapping the active Draw segment is Undo — the only undo affordance on this strip.
OnSize
Reports its child's layout size to onSize after each layout pass. Used by compose / tool screens to measure floating chrome (top bar, bottom strip, controls) so the editor's fitRect can subtract them from the full-bleed editor area.
PauseBarsPainter
Two parallel vertical bars matching iOS Telegram's pause glyph on the gallery's centre overlay (PlayPauseIconNode rendering of the .pause state). Sized to the same 18pt visual height as the play triangle so the two glyphs swap in place without a layout jump.
PhotoVideoSwap
The switch between photo and video.
PickerCameraBanner
Camera authorization action alongside the photo library.
PickerGridItem
Single grid cell — thumbnail + selection ring + duration badge for video. Telegram's MediaPickerGridItem shape: square aspect, ring at top-right with the 1-based pick index, video duration at bottom-left.
PickerLimitedBanner
Offers the system selector for the accessible subset of photos.
PickerPermissionPlaceholder
Replaces the library while photo access is unavailable.
PickerSourceRegistry
Build-stable registry of mounted picker thumbnail hero sources.
PlayTrianglePainter
Hand-tuned 15×18 right-pointing triangle with a +1.5pt rightward optical-centre bias, mirroring RadialStatusIconContentNode.swift:80-87. Used by both the chat bubble's play overlay and the gallery's center status overlay.
RadialRingPainter
Round-cap progress / spinner ring matching RadialProgressContentNode.swift:147-158.
RepaintBoundaryGallerySource
A concrete GallerySource backed by a RepaintBoundary reachable via boundaryKey. Suitable for any widget; the chat-side ChatMessageBubbleImageSource (Phase 13 / chat integration) wraps its image in a RepaintBoundary keyed by this implementation.
SelectedStrip
Horizontal carousel rendered when DisplayMode.selected. v1: a simple thumbnail strip — telegram-iOS's MediaPickerSelectedListNode wallpapered bubble-preview parity is post-v1, gated on banlu's bubble system catching up.
SelectionContext
Selection state for the picker. Mirrors telegram's TGMediaSelectionContext — ordered list of picked assets, capped at limit, with check-mark indices that follow the pick order (1-based to match the on-screen ring numerals).
Stroke
A finished stroke. thickness is in image-space (already divided by the camera scale at submission time) so the rendered viewport width stays constant across zoom levels.
StrokePoint
One sampled point along the user's drag. width is the rendered stroke width at this point in image-space px (already EMA-smoothed and velocity-modulated by DrawImageLayer.addPoint). velocity is kept for arrow direction lookback and tests that synthesize strokes.
TextAlignButton
Cycles left → centre → right, showing the active alignment.
TextControls
Bottom control strip for the text tool. Three rows top → bottom: style + alignment buttons, color row, action row. Every row matches its DrawControls counterpart's height, so swapping modes leaves the measured chrome height — and with it the host camera's fit — alone.
TextEditOverlay
Live keyboard editor for the entity entities is editing: a fade over the canvas with the string typed straight into place above the control strip.
TextEditPillPainter
Paints the pill behind the string under edit, in source-image pixels.
TextEntity
A text overlay in source-image coordinates: position is its centre and width the box its glyphs wrap in, with rotation in radians and scale applied about that centre.
TextEntityLayout
One TextEntity's string laid out in entity-local coordinates, spanning size with the glyphs inset by padding on the left.
TextStyleButton
Cycles TextEntityStyle, previewing the active one: "Aa" through the same TextEntityStyle.resolve the entity paints with — frame as the chip's fill, outline under the glyphs.
TgSpringCurve
Damped-spring curve equal to telegram's POP springs (springSpeed 7, springBounciness 1 → tension ≈285, friction ≈29, mass 1 — barely underdamped, ζ ≈ 0.86). Normalized to reach 1.0 at t = 1 over kTgSpring.
ThumbnailCache
In-memory LRU of XAssetThumbnails keyed by (assetId, sizePx). Telegram's PHCachingImageManager already caches on the native side; this Dart-side LRU keeps repeated rebuilds (scroll off-screen → back on) from re-encoding.
ToolTransition
Carries the screen-stack's transition animation down through the tool screen subtree so the chrome can animate independently of the preview. The preview reads nothing from this and stays visually static across the push / pop boundary — same model as telegram-iOS, where the previewContainerView doesn't move during animateOutToTool / animateInFromTool (only the host's button row does).
Touch
A press target that fades and grows while it is held, and gives a light haptic on a long press.
UserTransform
Image-space user transform: pan offset, scale, rotate, flip-X. Composes into a Matrix4 applied during paint and during export. Implements the + - * operators so Animator can tween between snapshots.
VideoCropGeometry
Baked crop/rotate/flip geometry for a video export, snapshotted from the entry's CropImageLayer at send time (CropImageLayer.exportMatrix + exportSize, already clamped to the chosen quality tier). transform is a row-major 3×3 affine mapping source pixel → output pixel coordinates ([a,b,tx, d,e,ty, 0,0,1]); the output canvas is outWidth×outHeight. Handed verbatim to XVideoExporter so the exported frames match the on-screen crop.
VideoDrawOverlay
Rasterised paint strokes for a video export — a transparent PNG at the upright source's pixel dimensions (the strokes stay vector on the entry's DrawImageLayer; this is the apply-time bake the natives composite over every frame before the crop affine).
VideoEditValues
Per-entry video edit state: the trim range and mute, the crop geometry and the rasterised paint overlay. Owned by ComposeEntry and carried by ComposeResult to the sender, which bakes it through XVideoExporter. Null bounds mean "keep the source edge"; a values object with nothing set is equivalent to no edits.
VideoMedia
A video.
VideoTrimScrubber
Telegram-style video trim scrubber + mute toggle (MediaScrubberComponent): a thumbnail strip with 14pt draggable trim handles, dimmed outside the selected range, and a playhead cursor tracking the preview. Dragging a handle pauses playback and scrubs the player to that boundary; release resumes the trim-looped preview. Minimum trim length is 1s.
XMedia
Outgoing media carrier. Every producer (camera, picker, file-pick, clipboard paste, voice recorder) emits one of these; every send-path consumes one. Unifies the prior CameraResult / PickedAsset / (file, isVideo) records, and pairs with dialog_bloc.sendMedia (a sealed-switch dispatcher) to replace the four parallel send methods.

Enums

BrushType
The brushes of the draw tool.
CameraButtonState
What the shutter button shows.
ComposePurpose
What the composed media is for.
DisplayMode
Picker body view mode — the grid (all) or a horizontal carousel of just the picked items (selected). 1:1 with telegram-iOS's MediaPickerScreen.DisplayMode.
EditorMode
Which control strip the draw editor shows.
EntitySelectionHit
The part of a selected entity's chrome under a pointer.
PickerViewKind
Which view a PickerGridItem is rendered in. Combined with the asset id in PickerSourceRegistry so grid and strip cells for the same XAsset.id resolve independently. The picker's transitionSourceFor closure reads its current _displayMode and picks the cell currently visible to the user — telegram's selectionNode.alpha > 0.0 routing translated into a Dart record key.
TextEntityStyle
How a text overlay's colour is spent between glyphs, frame and outline.

Mixins

Exporter
Layer mixin: rasterise into the editor's exported image. The host calls paintExport when the user submits the edit.
Painter
Layer mixin: paint into the editor's viewport every frame. The host passes its current camera (image-top-left → viewport).

Constants

entitySelectionColour → const Color
Colour of the selection frame and its handles.
entitySelectionFrameOutset → const double
How far past the entity's bounds the selection frame is hittable, in screen points.
entitySelectionStrokeWidth → const double
Width of the selection frame's and handles' strokes, in screen points.
entitySelectionViewHandleSize → const double
Side-handle hit target, in screen points.
kBrushDefaultColors → const Map<BrushType, Color>
Per-brush starting color. Each brush remembers its own color across switches; tapping a swatch updates the currently active brush's slot, not a global. Eraser keeps a slot for symmetry but its tip renders as a fixed pink in the picker.
kBrushDefaultThickness → const Map<BrushType, double>
Each brush's starting thickness, 0 to 1 of its width range.
kCenterStatusDiameter → const double
Gallery center-status disc diameter. Mirrors UniversalVideoGalleryItem.swift:1259-1262 statusDiameter = 50.0.
kCropDialGrabStrip → const double
Screen-px strip under the handle reach that the dial grabs alone.
kCropDialHandleReach → const double
How far CropAreaOverlay's bottom handles extend below crop.bottom: half the 44pt control. The extra 16pt slop stays on the crop side, so the ticks in the gutter are the dial's.
kCropDialNeedleGap → const double
Screen-px gap between the 0° tick and the needle.
kCropDialNeedleSize → const double
Screen-px side of the filled-triangle needle.
kCropDialTickInset → const double
Screen-px drop from crop.bottom to the dial's 0° tick.
kDisplayModeTransition → const Duration
Cross-fade duration when switching between grid and selected strip. Matches telegram's updateDisplayMode curve (MediaPickerScreen.swift:1257).
kDrawPalette → const List<Color>
Default eight-swatch palette. The last swatch is white so strokes read on dark photos.
kDrawToolElevation → const double
How much taller the selected brush stands.
kDrawToolHeight → const double
Height of a brush in the picker at rest.
kEditorSurfacePadding → const double
Vertical breathing room subtracted from the editor surface so the image never butts up against the top bar / caption strip. Telegram uses the same gutter on its media-editor surface.
kGalleryCloseFadeShrinkScale → const double
Close-transition shrink factor when the resolved destination rect is off-screen. The snapshot fades + scales down in place to this fraction of its source size — a translate-to-off-screen morph would look like a fast disappearing zoom. Banlu-specific UX choice; Telegram uses an explicit forceAway:true flag for the equivalent "no morph, just dismiss" path (ChatImageGalleryItem.swift:1494).
kGalleryCustomSpring → const SpringDescription
customSpring(damping=180, initialVelocity=0) resolved by CAAnimationUtils.swift:73-105 with mass=5.0 (line 88), stiffness=900.0 (line 89), damping=180 / vel=0 (lines 75-76, 86-87).
kGalleryDismissVelocity → const double
GalleryControllerNode.swift:567 — abs(velocity.y) > 1.0. iOS's UIScrollViewDelegate.scrollViewWillEndDragging reports velocity in points per millisecond (per Apple's docs), so the iOS constant 1.0 translates to 1000 px/s in Flutter's Velocity.pixelsPerSecond units.
kGalleryDismissXSlop → const double
SwipeToDismissGestureRecognizer.swift:85 — the dismiss recognizer fails itself once abs(translation.x) > 5.0 so a horizontal page swipe with vertical drift cedes cleanly to the pager. See §13a.9.
kGalleryIosSpringBezier → const Cubic
kCAMediaTimingFunctionSpring non-0.5s path — cubic-Bezier control points at CAAnimationUtils.swift:173: controlPoints: 0.380, 0.700, 0.125, 1.000.
kMediaFlightDuration → const Duration
Shared camera, compose and gallery route duration.
kPillVisibilityTransition → const Duration
Pill toggle entry/exit (scale + alpha). Telegram uses transform scale 0.01 → 1.0 + alpha on visibility flip.
kSelectedStripTileSize → const double
Logical-pixel size of each strip tile.
kStripItemTransition → const Duration
Insert/remove animation for strip tiles.
kTgSpring → const Duration
Settle duration paired with TgSpringCurve — the spring's amplitude decays below 0.2% inside this window.

Properties

editorInsets → Listenable
Safe-area and keyboard insets for the editor screens, taken from the binding rather than from MediaQuery: XRouter strips the keyboard's bottom inset out of the tree's viewInsets and viewPadding before a screen sees them.
no setter
editorKeyboardLift → double
Keyboard height net of the safe-area bottom it covers — how far bottom-anchored chrome rides up for its visible edge to sit on the keyboard's top.
no setter
editorSafeAreaBottom → double
The safe-area inset at the bottom.
no setter
editorSafeAreaTop → double
The safe-area inset at the top.
no setter
kCropDialBandHeight → double
Gutter between crop.bottom and the chrome, reserved by CropScreen's published fit rect: tall enough for the painted dial and for a grab strip clear of the bottom handle's reach.
final

Functions

computeCaptureTransform({required DeviceOrientation physical, required int sensorOrientation, required bool isFrontCamera}) → ({bool mirror, int rotationDegrees})
The rotation that turns sensor pixels upright for a capture at physical; never mirrors.
fitRect(Size? contentSize, Rect viewport) → Rect
Returns the rect inside viewport that an image of contentSize occupies when fitted (aspect-preserving) and centred — the same rect ZoomableContent lays the photo out to at fit zoom, and the same one iOS animates the open/close snapshot to via contentNode.view.bounds converted to self.view's coords (ChatImageGalleryItem.swift:1014-1016).
normalizeCameraCapture(File jpeg, {required DeviceOrientation physical, required int sensorOrientation, required bool isFrontCamera}) → Future<File>
Re-encodes a captured jpeg as an upright WebP file in the temporary directory, from the device's physical orientation at capture, the camera's sensorOrientation and whether it isFrontCamera.
paintCropRotationDial(Canvas canvas, {required Rect crop, required double rotate, required Rect viewport, required double scale}) → void
Paints the rotation dial's guides in image space: a tick circle whose lowest point marks rotate and a fixed needle under it.
paintTextEntity(Canvas canvas, TextEntity entity, Size reference) → void
Paints entity into a canvas whose coordinates are source-image pixels.
readJpegExifOrientation(Uint8List bytes) → int
Reads the EXIF Orientation tag (TIFF 0x0112) from a JPEG byte buffer. Returns 1..8 per the TIFF/EXIF convention, or 1 if not present.
readJpegRawDimensions(Uint8List bytes) → ({int height, int width})?
Raw stored pixel dimensions from a JPEG's SOFn marker (pre-EXIF).
stripJpegApp1(Uint8List bytes) → Uint8List
Return a copy of the JPEG with every APP1 (EXIF) segment removed. On non-JPEG or malformed input, returns the original bytes unchanged.
textEntityViewPose({Matrix4? viewerCamera, CropImageLayer? crop}) → ({double rotation, double scale})
Rotation and scale for a new text overlay so it appears upright at viewport-native size through the draw editor's view transform (viewer pan/zoom × crop imageTransform).
textPillPath(List<Rect> lineUsedRects) → Path
The filled background behind a block of text, over line rects that already carry their horizontal padding on both edges.
toSourcePoint(Offset viewport, {required Matrix4 hostCamera, Matrix4? viewerCamera, CropImageLayer? crop}) → Offset
Map a viewport-space pointer position into source-image space: undo the user's viewerCamera pan/zoom, then invert the cropped-view transform when crop has applied edits, else the plain hostCamera fit.
writeToolExportPng(Image image) → Future<File>
Encode image to a PNG temp file. Used by tool screens (crop, draw) when the user applies an edit. The PNG offload to a compute() isolate is parked behind Phase 6.

Typedefs

ComposeSubmitCallback = Future<ChatSendResult> Function(List<ComposeResult>)
Compose-side submit callback. The caller (chat_page) provides this so compose can pre-insert the chat bubble(s) before it pops — mirrors telegram's completion(results, finishedCallback) pattern from MediaEditorScreen.swift:7664. Returns the per-result cids + bubble-source finders so compose can target the close hero at the just-mounted bubbles without consulting any global registry.
TextEntityLine = ({Rect box, Rect pill})
A laid-out line. pill is box widened by the horizontal padding on each edge.