UNPKG

1.64 kBTypeScriptView Raw
1import { Extent } from './extent';
2import ImageBase from './ImageBase';
3import ImageState from './ImageState';
4
5/**
6 * A function that takes an {@link module:ol/Image~Image} for the image and a
7 * {string} for the src as arguments. It is supposed to make it so the
8 * underlying image {@link module:ol/Image~Image#getImage} is assigned the
9 * content specified by the src. If not specified, the default is
10 * <code>function(image, src) {
11 * image.getImage().src = src;
12 * }</code>Providing a custom imageLoadFunction can be useful to load images with
13 * post requests or - in general - through XHR requests, where the src of the
14 * image element would be set to a data URI when the content is loaded.
15 */
16export type LoadFunction = (p0: ImageWrapper, p1: string) => void;
17export default class ImageWrapper extends ImageBase {
18 constructor(
19 extent: Extent,
20 resolution: number | undefined,
21 pixelRatio: number,
22 src: string,
23 crossOrigin: string,
24 imageLoadFunction: LoadFunction,
25 );
26 protected state: ImageState;
27 getImage(): HTMLCanvasElement | HTMLImageElement | HTMLVideoElement;
28 /**
29 * Load the image or retry if loading previously failed.
30 * Loading is taken care of by the tile queue, and calling this method is
31 * only needed for preloading or for reloading in case of an error.
32 */
33 load(): void;
34 setImage(image: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement): void;
35}
36export function listenImage(
37 image: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement,
38 loadHandler: () => any,
39 errorHandler: () => any,
40): () => void;