API Reference / @gtkx/cairo / ImageSurface
Class: ImageSurface
Defined in: surface.d.ts:68
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:74
Creates an image surface of the given pixel format and size.
Parameters
format
width
number
height
number
Returns
ImageSurface
Overrides
Properties
__type__
__type__:
bigint
Defined in: surface.d.ts:19
GType of CairoSurface, the boxed type this class is registered under.
Inherited from
Methods
copyPage()
copyPage():
void
Defined in: surface.d.ts:55
Emits the current page and keeps its content for the next one, on paged backends.
Returns
void
Inherited from
finish()
finish():
void
Defined in: surface.d.ts:25
Finishes the surface and drops its backend resources; further drawing reports an error.
Returns
void
Inherited from
flush()
flush():
void
Defined in: surface.d.ts:27
Performs any pending drawing so the backend storage is up to date.
Returns
void
Inherited from
getContent()
getContent():
Content
Defined in: surface.d.ts:33
Returns whether the surface holds color, alpha or both.
Returns
Inherited from
getData()
getData():
Uint8Array
Defined in: surface.d.ts:84
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:29
Returns the raw handle of the device behind the surface, or null when it has none.
Returns
ExternalObject<Handle> | null
Inherited from
getDeviceOffset()
getDeviceOffset():
DeviceOffset
Defined in: surface.d.ts:41
Returns the offset added to device coordinates when drawing onto the surface.
Returns
Inherited from
getDeviceScale()
getDeviceScale():
DeviceScale
Defined in: surface.d.ts:43
Returns the scale applied between user and device units.
Returns
Inherited from
getFallbackResolution()
getFallbackResolution():
FallbackResolution
Defined in: surface.d.ts:49
Returns the resolution used when vector content has to be rasterized.
Returns
Inherited from
getFontOptions()
getFontOptions():
FontOptions
Defined in: surface.d.ts:31
Returns the font options the surface's backend prefers for rendering text.
Returns
Inherited from
getFormat()
getFormat():
Format
Defined in: surface.d.ts:80
Returns the pixel format of the surface.
Returns
getHeight()
getHeight():
number
Defined in: surface.d.ts:78
Returns the height of the surface in pixels.
Returns
number
getReferenceCount()
getReferenceCount():
number
Defined in: surface.d.ts:53
Returns the reference count of the surface.
Returns
number
Inherited from
getStride()
getStride():
number
Defined in: surface.d.ts:82
Returns the number of bytes between the starts of consecutive rows.
Returns
number
getType()
getType():
SurfaceType
Defined in: surface.d.ts:51
Returns the backend type of the surface.
Returns
Inherited from
getWidth()
getWidth():
number
Defined in: surface.d.ts:76
Returns the width of the surface in pixels.
Returns
number
hasShowTextGlyphs()
hasShowTextGlyphs():
boolean
Defined in: surface.d.ts:59
Returns whether the surface supports Context.showTextGlyphs natively.
Returns
boolean
Inherited from
mapToImage()
mapToImage(
extents):Surface
Defined in: surface.d.ts:63
Returns an image surface giving direct access to the pixels of extents; release it with unmapImage.
Parameters
extents
Returns
Inherited from
markDirty()
markDirty():
void
Defined in: surface.d.ts:35
Tells cairo the surface's storage was modified outside of cairo.
Returns
void
Inherited from
markDirtyRectangle()
markDirtyRectangle(
x,y,width,height):void
Defined in: surface.d.ts:37
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
setDeviceOffset()
setDeviceOffset(
xOffset,yOffset):void
Defined in: surface.d.ts:39
Sets the offset added to device coordinates when drawing onto the surface.
Parameters
xOffset
number
yOffset
number
Returns
void
Inherited from
setDeviceScale()
setDeviceScale(
xScale,yScale):void
Defined in: surface.d.ts:45
Sets the scale applied between user and device units.
Parameters
xScale
number
yScale
number
Returns
void
Inherited from
setFallbackResolution()
setFallbackResolution(
xPixelsPerInch,yPixelsPerInch):void
Defined in: surface.d.ts:47
Sets the resolution used when vector content has to be rasterized.
Parameters
xPixelsPerInch
number
yPixelsPerInch
number
Returns
void
Inherited from
showPage()
showPage():
void
Defined in: surface.d.ts:57
Emits the current page and starts a blank one, on paged backends.
Returns
void
Inherited from
status()
status():
Status
Defined in: surface.d.ts:23
Returns the error status of the surface, Status.SUCCESS when it is usable.
Returns
Inherited from
supportsMimeType()
supportsMimeType(
mimeType):boolean
Defined in: surface.d.ts:61
Returns whether the surface can embed data of the given MIME type.
Parameters
mimeType
string
Returns
boolean
Inherited from
unmapImage()
unmapImage(
image):void
Defined in: surface.d.ts:65
Uploads the pixels of image, obtained from mapToImage, back to the surface and releases it.
Parameters
image
Returns
void
Inherited from
writeToPng()
writeToPng(
filename):Status
Defined in: surface.d.ts:21
Writes the surface to a PNG file at filename and returns the resulting status.
Parameters
filename
string
Returns
Inherited from
create()
staticcreate(format,width,height):ImageSurface
Defined in: surface.d.ts:70
Creates an image surface of the given pixel format and size, the same as new ImageSurface(...).
Parameters
format
width
number
height
number
Returns
ImageSurface
createForRectangle()
staticcreateForRectangle(target,x,y,width,height):Surface
Defined in: surface.d.ts:17
Creates a surface that draws onto the given rectangle of target.
Parameters
target
x
number
y
number
width
number
height
number
Returns
Inherited from
createFromPng()
staticcreateFromPng(filename):ImageSurface
Defined in: surface.d.ts:72
Loads a PNG file into a new image surface; throws when the file is missing or invalid.
Parameters
filename
string
Returns
ImageSurface
createSimilar()
staticcreateSimilar(other,content,width,height):Surface
Defined in: surface.d.ts:13
Creates a surface of the given content and size as compatible as possible with other.
Parameters
other
content
width
number
height
number
Returns
Inherited from
createSimilarImage()
staticcreateSimilarImage(other,format,width,height):ImageSurface
Defined in: surface.d.ts:15
Creates an image surface of the given format and size as compatible as possible with other.
Parameters
other
format
width
number
height
number
Returns
ImageSurface