Table of Contents

Class SKImagePyramidController

Namespace
SkiaSharp.Extended
Assembly
SkiaSharp.Extended.dll

Orchestrates the image pyramid rendering pipeline: viewport management, tile scheduling, cache management, and rendering.

public class SKImagePyramidController : IDisposable
Inheritance
SKImagePyramidController
Implements
Inherited Members

Remarks

This class handles only tile and rendering concerns. Animation, spring physics, and gesture recognition belong in the consuming layer.

Typical usage:

  1. Call SetProvider(ISKImagePyramidTileProvider) to configure the tile fetch/cache pipeline.
  2. Call Load(ISKImagePyramidSource) to load an image.
  3. Call SetControlSize(double, double) when the canvas size changes.
  4. Call Update() to schedule tile loads each frame.
  5. Call Render(ISKImagePyramidRenderer) from your canvas paint callback.

Constructors

SKImagePyramidController(ISKImagePyramidTileCache?)

Initializes a new SKImagePyramidController.

Properties

AspectRatio

The aspect ratio of the loaded image (width/height). 0 if not loaded.

Cache

The in-memory render cache. Exposed for observability (count, diagnostics).

EnableLodBlending

Whether to draw lower-resolution fallback tiles while hi-res tiles are loading (LOD blending). Default is true.

IsIdle

Whether the controller has no pending tile loads.

NativeZoom

The zoom level at which one image pixel maps to exactly one screen pixel. Returns 0 if no image is loaded.

PendingTileCount

Number of tile fetches currently in flight.

Provider

The active tile provider, or null if not set.

Source

The active tile source, or null if not loaded.

SubImages

The sub-images from the loaded DZC, or empty if not loaded from a DZC.

TileLayout

The tile layout calculator.

Viewport

The current viewport.

Methods

Dispose()
GetZoomRect()

Returns the logical rectangle visible at the current viewport state.

Load(ISKImagePyramidSource)

Loads a tile source. Resets the viewport to show the full image. Provider must be set first via SetProvider(ISKImagePyramidTileProvider).

Load(ISKImagePyramidSource, ISKImagePyramidTileProvider)

Convenience: sets the provider and loads a source in one call.

Load(SKImagePyramidDziCollectionSource, ISKImagePyramidTileProvider)

Loads a DZC collection source. Populates SubImages with the items in the collection. Does NOT set a renderable tile source — listen for CollectionOpenSucceeded and then call Load(ISKImagePyramidSource) with a specific sub-image source to render.

Pan(double, double)

Pans by the given screen-space delta.

Render(ISKImagePyramidRenderer)

Executes the two-pass LOD rendering pipeline using the provided renderer.

ResetView()

Resets the viewport to show the entire image.

RetryFailedTiles()

Clears all failure state, allowing failed tiles to be re-fetched. Call after network recovery or when retrying is appropriate.

SetControlSize(double, double)

Sets the control (canvas) size. Refits the viewport when the user has not manually zoomed.

SetProvider(ISKImagePyramidTileProvider)

Sets the tile provider (fetch + cache pipeline). Cancels pending loads, clears failed tiles and render buffer, and fires InvalidateRequired. The controller does NOT own the provider lifecycle — the caller manages disposal.

SetViewport(double, double, double)

Sets the viewport directly and constrains it.

SetZoom(double)

Sets an absolute zoom level (1.0 = image fills the control width).

Update()

Schedules loading for visible tiles. Call from your render loop on every frame.

ZoomAboutLogicalPoint(double, double, double)

Zooms about a logical point. Factor > 1 zooms in, < 1 zooms out.

ZoomAboutScreenPoint(double, double, double)

Zooms about a screen-space point.

Events

CollectionOpenSucceeded

Fired when a DZC collection is successfully loaded and SubImages is populated.

ImageOpenFailed

Fired when the image source fails to load.

ImageOpenSucceeded

Fired when the image source is loaded successfully.

InvalidateRequired

Fired when new tiles are loaded and the view needs repainting.

TileFailed

Fired when a tile fails to load.

ViewportChanged

Fired when the viewport position or zoom level changes.