Documentation/GdiBitmap
class

GdiBitmap

js/foo_uie_jsplitter.js:4183
GdiBitmap(arg)

Parameters

NameTypeDescription
argGdiBitmap
propertyreadonly

Height

js/foo_uie_jsplitter.js:4189
Height: number
propertyreadonly

Width

js/foo_uie_jsplitter.js:4195
Width: number
method

ApplyAlpha

js/foo_uie_jsplitter.js:4201
ApplyAlpha(alpha)

Parameters

NameTypeDescription
alphanumber

Valid values 0-255.

Returns

GdiBitmap
method

ApplyMask

js/foo_uie_jsplitter.js:4207
ApplyMask(img)

Changes will be saved in the current bitmap.

Parameters

NameTypeDescription
imgGdiBitmap

Example source

method

Clone

js/foo_uie_jsplitter.js:4216
Clone(x, y, w, h)

Parameters

NameTypeDescription
xnumber
ynumber
wnumber
hnumber

Returns

GdiBitmap
method

CreateRawBitmap

js/foo_uie_jsplitter.js:4225
CreateRawBitmap()

Create a DDB bitmap from GdiBitmap, which is used in GdiDrawBitmap

Returns

GdiRawBitmap
method

GetColourScheme

js/foo_uie_jsplitter.js:4232
GetColourScheme(max_count)

Takes the top of colors found in the image

Parameters

NameTypeDescription
max_countnumber

Returns

Array<number>
method

GetColourSchemeJSON

js/foo_uie_jsplitter.js:4239
GetColourSchemeJSON(max_count)

Returns a JSON array in string form so you need to use JSON.parse() on the result.
Each entry in the array is an object which contains colour and frequency values.
Uses a different method for calculating colours than GetColourScheme.
Image is automatically resized during processing for performance reasons so there's no need to resize before calling the method.

Parameters

NameTypeDescription
max_countnumber

Returns

string

Example

// See docs\Helpers.js for "toRGB" function.
img = ... // use utils.GetAlbumArtV2 / gdi.Image / etc
colours = JSON.parse(img.GetColourSchemeJSON(5));
console.log(colours[0].col); // -4194304
console.log(colours[0].freq); // 0.34
console.log(toRGB(colours[0].col)); // [192, 0, 0]
method

GetColourSchemeJSONV2

js/foo_uie_jsplitter.js:4259
GetColourSchemeJSONV2(max_count, min_chroma)

Returns a JSON array in string form so you need to use JSON.parse() on the result.
Each entry in the array is an object which contains colour and frequency values.
Uses a different method than GetColourSchemeJSON for calculating colours (K-means++ with Oklab).

Parameters

NameTypeDescription
max_countnumber
min_chroma = 0.0optionalnumber

minimal chroma value for choosing start cluster pixel

Returns

string
method

GetGraphics

js/foo_uie_jsplitter.js:4270
GetGraphics()

Note: don't forget to use ReleaseGraphics after work on GdiGraphics is done!

Returns

GdiGraphics
method

GetPixelData

js/foo_uie_jsplitter.js:4277
GetPixelData(format)

Extract raw pixels from bitmap as a byte array in specified pixel format

Parameters

NameTypeDescription
format = "bgra32"optionalstring

Pixel format string (default: "bgra32") Supported formats:
"bgra32" 32bpp BGRA
"rgba32" 32bpp RGBA
"bgr24" 24bpp BGR
"rgb24" 24bpp RGB

Returns

Uint8Array

null if was an error (for example, bitmap in unsupported format or unsupported format specified)

Example

const img = gdi.Image(`${fb.ComponentPath}\\samples\\d2d\\images\\Field.jpg`);

let imgPixelData = img.GetPixelData();

utils.WriteBinaryFile("D:\\Field.bin", imgPixelData);

let rData = utils.ReadBinaryFile("D:\\Field.bin");

let rImg = gdi.CreateImageFromPixelData(rData, 2208, 1242);

function on_paint(gr) {
    gr.DrawImage(rImg, 0, 0, img.Width, img.Height, 0, 0, img.Width, img.Height);
}
method

InvertColours

js/foo_uie_jsplitter.js:4304
InvertColours()

Inverts the colours in a bitmap, to create a negative image. i.e. White becomes black, black becomes white, etc.

Returns

GdiBitmap
method

ReleaseGraphics

js/foo_uie_jsplitter.js:4311
ReleaseGraphics(gr)

Parameters

NameTypeDescription
grGdiGraphics
method

Resize

js/foo_uie_jsplitter.js:4316
Resize(w, h, mode)

Parameters

NameTypeDescription
wnumber
hnumber
mode = 0optionalnumber

See InterpolationMode

Returns

GdiBitmap
method

RotateFlip

js/foo_uie_jsplitter.js:4324
RotateFlip(mode)

Changes will be saved in the current bitmap.

Parameters

NameTypeDescription
modenumber

See RotateFlipType

method

SaveAs

js/foo_uie_jsplitter.js:4331
SaveAs(path, format)

Parameters

NameTypeDescription
pathstring

Full path including file extension. The parent folder must already exist.

format = 'image/png'optionalstring

"image/png"
"image/bmp"
"image/jpeg"
"image/gif"
"image/tiff"

Returns

boolean

Example

let img = utils.GetAlbumArtEmbedded(fb.GetFocusItem().RawPath, 0);
if (img) {
    img.SaveAs("D:\\export.jpg", "image/jpeg");
}
method

StackBlur

js/foo_uie_jsplitter.js:4349
StackBlur(radius)

Changes will be saved in the current bitmap.

Parameters

NameTypeDescription
radiusnumber

Valid values 2-254.

Examples

<caption>Blur image<caption>
// `samples/basic/StackBlur (image).js`
<caption>Blur text<caption>
// `samples/basic/StackBlur (text).js`