/** * slide.ts * * Represents an opened whole-slide image. Created by OpenSlide.open(). * Metadata properties are synchronous (eagerly loaded), while pixel * operations are async (delegated to a worker). */ import type { Dimensions, SlideInfo } from './types.js'; /** Per-call options for worker-delegated operations. */ export interface SendOptions { /** Transferables to move (not copy) to the worker. */ transfer?: Transferable[]; /** * Cancels the operation if it is still queued in the worker (rejects with * OpenSlideAbortError). An already-executing read runs to completion. */ signal?: AbortSignal; } /** Function type for sending a command to a worker and awaiting the response. */ export type SendCommand = (cmd: Record, opts?: SendOptions) => Promise; export declare class Slide { /** @internal */ private _send; /** @internal */ private _handle; /** @internal */ private _mountId; /** @internal */ private _info; /** @internal */ private _closed; /** @internal */ constructor(send: SendCommand, handle: number, mountId: string, info: SlideInfo); /** Number of pyramid levels in the slide. */ get levelCount(): number; /** Dimensions of level 0 (full resolution). */ get dimensions(): Dimensions; /** Dimensions of each pyramid level. */ get levelDimensions(): readonly Dimensions[]; /** Downsample factor for each pyramid level. */ get levelDownsamples(): readonly number[]; /** Slide metadata properties (vendor, MPP, objective power, etc.). */ get properties(): ReadonlyMap; /** Names of associated images (e.g., "label", "thumbnail", "macro"). */ get associatedImageNames(): readonly string[]; /** * Find the best pyramid level for a given downsample factor. * Returns the level index whose downsample is closest to (but not * exceeding) the requested factor. */ getBestLevelForDownsample(downsample: number): number; /** * Read a region of pixel data from the slide. * * @param x - Top-left x coordinate in level-0 reference frame. * @param y - Top-left y coordinate in level-0 reference frame. * @param level - Pyramid level to read from. * @param width - Width in pixels at the target level. * @param height - Height in pixels at the target level. * @param options.signal - Cancels the read while it is still queued in the * worker (rejects with OpenSlideAbortError); an executing read finishes. * @returns ImageData containing RGBA pixel data. */ readRegion(x: number, y: number, level: number, width: number, height: number, options?: { signal?: AbortSignal; }): Promise; /** * Read an associated image (e.g., slide label or macro image). * * @param name - Name of the associated image. * @returns ImageData containing RGBA pixel data. */ readAssociatedImage(name: string): Promise; /** * Get the dimensions of an associated image. */ getAssociatedImageDimensions(name: string): Promise; /** * Read the ICC color profile embedded in the slide, if any. * @returns Raw ICC profile bytes, or null if none. */ getIccProfile(): Promise; /** Close the slide and release WASM resources. */ close(): Promise; /** Support for `await using slide = ...` (explicit resource management). */ [Symbol.asyncDispose](): Promise; private ensureOpen; } //# sourceMappingURL=slide.d.ts.map