Skip to content

API Reference / @gtkx/cairo / ImageSurface

Class: ImageSurface ​

Defined in: surface.d.ts:63

A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing.

Extends ​

Constructors ​

Constructor ​

new ImageSurface(format, width, height): ImageSurface

Defined in: surface.d.ts:69

Creates an image surface of the given pixel format and size.

Parameters ​

format ​

Format

width ​

number

height ​

number

Returns ​

ImageSurface

Overrides ​

Surface.constructor

Properties ​

__type__ ​

__type__: bigint

Defined in: surface.d.ts:18

GType of CairoSurface, the boxed type this class is registered under.

Inherited from ​

Surface.__type__

Methods ​

copyPage() ​

copyPage(): void

Defined in: surface.d.ts:54

Emits the current page and keeps its content for the next one, on paged backends.

Returns ​

void

Inherited from ​

Surface.copyPage


finish() ​

finish(): void

Defined in: surface.d.ts:24

Finishes the surface and drops its backend resources; further drawing reports an error.

Returns ​

void

Inherited from ​

Surface.finish


flush() ​

flush(): void

Defined in: surface.d.ts:26

Performs any pending drawing so the backend storage is up to date.

Returns ​

void

Inherited from ​

Surface.flush


getContent() ​

getContent(): Content

Defined in: surface.d.ts:32

Returns whether the surface holds color, alpha or both.

Returns ​

Content

Inherited from ​

Surface.getContent


getData() ​

getData(): Uint8Array

Defined in: surface.d.ts:79

Returns a copy of the pixel data, getStride() * getHeight() bytes in the surface's format.

Returns ​

Uint8Array


getDevice() ​

getDevice(): ExternalObject<Handle> | null

Defined in: surface.d.ts:28

Returns the raw handle of the device behind the surface, or null when it has none.

Returns ​

ExternalObject<Handle> | null

Inherited from ​

Surface.getDevice


getDeviceOffset() ​

getDeviceOffset(): DeviceOffset

Defined in: surface.d.ts:40

Returns the offset added to device coordinates when drawing onto the surface.

Returns ​

DeviceOffset

Inherited from ​

Surface.getDeviceOffset


getDeviceScale() ​

getDeviceScale(): DeviceScale

Defined in: surface.d.ts:42

Returns the scale applied between user and device units.

Returns ​

DeviceScale

Inherited from ​

Surface.getDeviceScale


getFallbackResolution() ​

getFallbackResolution(): FallbackResolution

Defined in: surface.d.ts:48

Returns the resolution used when vector content has to be rasterized.

Returns ​

FallbackResolution

Inherited from ​

Surface.getFallbackResolution


getFontOptions() ​

getFontOptions(): FontOptions

Defined in: surface.d.ts:30

Returns the font options the surface's backend prefers for rendering text.

Returns ​

FontOptions

Inherited from ​

Surface.getFontOptions


getFormat() ​

getFormat(): Format

Defined in: surface.d.ts:75

Returns the pixel format of the surface.

Returns ​

Format


getHeight() ​

getHeight(): number

Defined in: surface.d.ts:73

Returns the height of the surface in pixels.

Returns ​

number


getReferenceCount() ​

getReferenceCount(): number

Defined in: surface.d.ts:52

Returns the reference count of the surface.

Returns ​

number

Inherited from ​

Surface.getReferenceCount


getStride() ​

getStride(): number

Defined in: surface.d.ts:77

Returns the number of bytes between the starts of consecutive rows.

Returns ​

number


getType() ​

getType(): SurfaceType

Defined in: surface.d.ts:50

Returns the backend type of the surface.

Returns ​

SurfaceType

Inherited from ​

Surface.getType


getWidth() ​

getWidth(): number

Defined in: surface.d.ts:71

Returns the width of the surface in pixels.

Returns ​

number


hasShowTextGlyphs() ​

hasShowTextGlyphs(): boolean

Defined in: surface.d.ts:58

Returns whether the surface supports Context.showTextGlyphs natively.

Returns ​

boolean

Inherited from ​

Surface.hasShowTextGlyphs


markDirty() ​

markDirty(): void

Defined in: surface.d.ts:34

Tells cairo the surface's storage was modified outside of cairo.

Returns ​

void

Inherited from ​

Surface.markDirty


markDirtyRectangle() ​

markDirtyRectangle(x, y, width, height): void

Defined in: surface.d.ts:36

Tells cairo the given rectangle of the surface's storage was modified outside of cairo.

Parameters ​

x ​

number

y ​

number

width ​

number

height ​

number

Returns ​

void

Inherited from ​

Surface.markDirtyRectangle


setDeviceOffset() ​

setDeviceOffset(xOffset, yOffset): void

Defined in: surface.d.ts:38

Sets the offset added to device coordinates when drawing onto the surface.

Parameters ​

xOffset ​

number

yOffset ​

number

Returns ​

void

Inherited from ​

Surface.setDeviceOffset


setDeviceScale() ​

setDeviceScale(xScale, yScale): void

Defined in: surface.d.ts:44

Sets the scale applied between user and device units.

Parameters ​

xScale ​

number

yScale ​

number

Returns ​

void

Inherited from ​

Surface.setDeviceScale


setFallbackResolution() ​

setFallbackResolution(xPixelsPerInch, yPixelsPerInch): void

Defined in: surface.d.ts:46

Sets the resolution used when vector content has to be rasterized.

Parameters ​

xPixelsPerInch ​

number

yPixelsPerInch ​

number

Returns ​

void

Inherited from ​

Surface.setFallbackResolution


showPage() ​

showPage(): void

Defined in: surface.d.ts:56

Emits the current page and starts a blank one, on paged backends.

Returns ​

void

Inherited from ​

Surface.showPage


status() ​

status(): Status

Defined in: surface.d.ts:22

Returns the error status of the surface, Status.SUCCESS when it is usable.

Returns ​

Status

Inherited from ​

Surface.status


supportsMimeType() ​

supportsMimeType(mimeType): boolean

Defined in: surface.d.ts:60

Returns whether the surface can embed data of the given MIME type.

Parameters ​

mimeType ​

string

Returns ​

boolean

Inherited from ​

Surface.supportsMimeType


writeToPng() ​

writeToPng(filename): Status

Defined in: surface.d.ts:20

Writes the surface to a PNG file at filename and returns the resulting status.

Parameters ​

filename ​

string

Returns ​

Status

Inherited from ​

Surface.writeToPng


create() ​

static create(format, width, height): ImageSurface

Defined in: surface.d.ts:65

Creates an image surface of the given pixel format and size, the same as new ImageSurface(...).

Parameters ​

format ​

Format

width ​

number

height ​

number

Returns ​

ImageSurface


createForRectangle() ​

static createForRectangle(target, x, y, width, height): Surface

Defined in: surface.d.ts:16

Creates a surface that draws onto the given rectangle of target.

Parameters ​

target ​

Surface

x ​

number

y ​

number

width ​

number

height ​

number

Returns ​

Surface

Inherited from ​

Surface.createForRectangle


createFromPng() ​

static createFromPng(filename): ImageSurface

Defined in: surface.d.ts:67

Loads a PNG file into a new image surface; throws when the file is missing or invalid.

Parameters ​

filename ​

string

Returns ​

ImageSurface


createSimilar() ​

static createSimilar(other, content, width, height): Surface

Defined in: surface.d.ts:12

Creates a surface of the given content and size as compatible as possible with other.

Parameters ​

other ​

Surface

content ​

Content

width ​

number

height ​

number

Returns ​

Surface

Inherited from ​

Surface.createSimilar


createSimilarImage() ​

static createSimilarImage(other, format, width, height): ImageSurface

Defined in: surface.d.ts:14

Creates an image surface of the given format and size as compatible as possible with other.

Parameters ​

other ​

Surface

format ​

Format

width ​

number

height ​

number

Returns ​

ImageSurface

Inherited from ​

Surface.createSimilarImage