import type { ImageSerializationMode } from '../index';
import type { DeepPartial } from '../utils/utils';
import { PartiallyConstructible } from '../utils/utils';
import { BufferImageLoadOptions, EncodeImageOptions, ImageInfo, ImageRefPoolSnapshot, PathImageLoadOptions, SaveImageOptions } from './ImageRefTypes';
export declare function autorelease<TReturn>(computation: () => TReturn | Promise<TReturn>): Promise<TReturn>;
export declare abstract class AutoReleasable extends PartiallyConstructible {
    private retained;
    protected constructor(uniqueId?: string);
    abstract release(): void;
    isRetained(): boolean;
    retain(): void;
}
export declare class ImageRef extends AutoReleasable {
    readonly uniqueId?: string;
    private _buffer?;
    private released;
    get buffer(): string | undefined;
    private constructor();
    static From(source: DeepPartial<ImageRef>): ImageRef;
    static deserialize(serializedRef: DeepPartial<ImageRef>): ImageRef;
    /**
     * Converts the Image Ref to Json representation
     */
    serialize(imageSerializationMode: ImageSerializationMode): Promise<DeepPartial<ImageRef | null>>;
    /**
     * Creates ImageRef with uniqueId from the file uri to an image.
     */
    static fromImageFileUri(uri: string, options?: PathImageLoadOptions): Promise<ImageRef | null>;
    /**
     * Creates ImageRef with uniqueId from base64 encoded buffer, e.g. from jpeg.
     */
    static fromEncodedBuffer(buffer: string, options?: BufferImageLoadOptions): Promise<ImageRef | null>;
    /**
     * Creates a deep copy of the image.
     * If uniqueId is not set or the image is already released, an exception will be thrown.
     */
    clone(): Promise<ImageRef | null>;
    /**
     * Compresses ImageRef and stores it either on disk or in memory according to global settings.
     * If uniqueId is not set or the image is already released, an exception will be thrown.
     */
    hibernate(): Promise<void>;
    /**
     * Releases native resources stored by the ref.
     * If two different ImageRef objects have the same uniqueId both of them become cleared.
     * If uniqueId is not set or the image is already released, an exception will be thrown.
     */
    clear(): Promise<void>;
    /**
     * Information about stored image as reference.
     * If uniqueId is not set or the image is already released, an exception will be thrown.
     */
    info(): Promise<ImageInfo | null>;
    /**
     * Saves the stored image with the given options.
     * If uniqueId is not set or the image is already released, an exception will be thrown.
     */
    saveImage(path: string, options?: SaveImageOptions): Promise<boolean>;
    /**
     * Encode image.
     */
    encodeInPlace(): Promise<void>;
    /**
     * Returns the stored image as base64.
     */
    encodeImage(options?: EncodeImageOptions): Promise<string | null>;
    /**
     * Releases strong reference to the image.
     * If uniqueId to the image is not set, an exception will be thrown.
     */
    release(): void;
    /**
     * Returns a snapshot of all alive ImageRefs.
     * The snapshot contains a list of ImageRefs with information such as in-memory size.
     */
    static makeSnapshot(): Promise<ImageRefPoolSnapshot | null>;
    /**
     * Releases all alive images despite any existing references.
     */
    static releaseAll(): void;
    private throwErrorIfUniqueIdIsMissing;
    private throwErrorIfReleased;
}
