Version:
class

Image

The class represents generic image data

typescript
class Image

Properties

NameTypeDescription
readonly bitsPerPixelnumberNumber of bits per single pixel
readonly byteWidthnumberTotal number of bytes per image line
readonly channelsnumberAmount of channels
readonly colorModeColorModeAn images color mode, defaults to(default: ColorMode.BGR)
readonly dataBufferGeneric data
readonly heightnumberheight in pixels
readonly idstringImage identifier
readonly pixelDensity{ scaleX: number; scaleY: number }Object containing scale info to work with e.g. Retina display data where the reported display size and pixel size differ (Default: {scaleX: 1.0, scaleY: 1.0})(default: ...)
readonly widthnumberwidth in pixels

Methods

toBGR

toBGR(): Promise<Image>

converts an from RGB color mode to RGB

Returns

Promise<Image>

toDataURL

toDataURL(fileType: FileType): string

encodes this as a base64 data URL string

Parameters

fileTypeFileTypeThe target image format

Returns

string

toRGB

toRGB(): Promise<Image>

converts an from BGR color mode (default within nut.js) to RGB

Returns

Promise<Image>

fromRGBData

fromRGBData(width: number, height: number, data: Buffer, channels: number, id: string, bitsPerPixel: number, byteWidth: number): Image

creates an from provided RGB data

Parameters

widthnumber
heightnumber
dataBuffer
channelsnumber
idstring
bitsPerPixelnumber
byteWidthnumber

Returns

Image

Was this page helpful?