Table of Contents

Class SKImagePyramidViewport

Namespace
SkiaSharp.Extended
Assembly
SkiaSharp.Extended.dll

Manages the Deep Zoom viewport — the logical window into the image. Handles coordinate conversions between element (screen), logical (0-1 normalized), and image pixel spaces. Mirrors Silverlight's MultiScaleImage viewport behavior.

public class SKImagePyramidViewport
Inheritance
SKImagePyramidViewport
Inherited Members

Constructors

SKImagePyramidViewport()

Fields

MinViewportWidth

Minimum viewport width to prevent extreme zoom (corresponds to ~1,000,000x zoom).

Properties

AspectRatio

Image aspect ratio (width/height).

ControlHeight

Height of the control in screen pixels.

ControlWidth

Width of the control in screen pixels.

MaxViewportWidth

Maximum viewport width (minimum zoom level). Default 1.0 means the image fills the control. Set higher (e.g., 10.0) to allow zooming out so the image appears as a small thumbnail.

Scale

Pixels per logical unit — the effective scale factor.

ViewportHeight

The logical height visible, derived from ViewportWidth and control aspect ratio.

ViewportOriginX

Top-left X in logical coordinates (0-1 normalized to image width).

ViewportOriginY

Top-left Y in logical coordinates.

ViewportWidth

Logical width of the visible area. 1.0 = full image width fits in control. Less than 1.0 = zoomed in. Greater than 1.0 = zoomed out. Minimum width is clamped to prevent extreme zoom levels.

Zoom

Current zoom level (1.0 = fits width, higher = zoomed in).

Methods

Constrain()

Constrains the viewport. When zoomed out past the image, the image is centered within the viewport.

ElementToLogicalPoint(double, double)

Converts a screen-space point to logical coordinates.

FitToView()

Sets the viewport to "fit" mode — the entire image is visible and centered. Does not alter MaxViewportWidth; callers may zoom out past fit.

GetLogicalBounds()

Gets the logical bounds of the current viewport (Left, Top, Right, Bottom).

GetState()

Creates a snapshot of the current viewport state.

GetZoomRect(double)

Returns the logical rectangle that is currently visible in the control at the given viewport width. Height is derived from the control's pixel dimensions, not the image aspect ratio, so that the returned rect always matches the visible area regardless of control shape.

LogicalToElementPoint(double, double)

Converts a logical point to screen-space coordinates.

PanByScreenDelta(double, double)

Pans by a delta in screen pixels.

SetState(SKImagePyramidViewportState)

Restores a previously captured viewport state.

ZoomAboutLogicalPoint(double, double, double)

Zooms about a logical point. The point under the cursor stays fixed on screen. This is the core zoom algorithm from Silverlight's MultiScaleImage.ZoomAboutLogicalPoint.