GdiBitmap
GdiBitmap(arg)
Parameters
| Name | Type | Description |
|---|---|---|
arg | GdiBitmap |
GdiBitmap(arg)
| Name | Type | Description |
|---|---|---|
arg | GdiBitmap |
Height: number
Width: number
ApplyAlpha(alpha)
| Name | Type | Description |
|---|---|---|
alpha | number | Valid values 0-255. |
ApplyMask(img)
Changes will be saved in the current bitmap.
| Name | Type | Description |
|---|---|---|
img | GdiBitmap |
Clone(x, y, w, h)
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number |
CreateRawBitmap()
Create a DDB bitmap from GdiBitmap, which is used in GdiDrawBitmap
GetColourScheme(max_count)
Takes the top of colors found in the image
| Name | Type | Description |
|---|---|---|
max_count | number |
Array<number>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.
| Name | Type | Description |
|---|---|---|
max_count | number |
string// 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]
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).
| Name | Type | Description |
|---|---|---|
max_count | number | |
min_chroma = 0.0optional | number | minimal chroma value for choosing start cluster pixel |
stringGetGraphics()
Note: don't forget to use ReleaseGraphics after work on GdiGraphics is done!
GetPixelData(format)
Extract raw pixels from bitmap as a byte array in specified pixel format
| Name | Type | Description |
|---|---|---|
format = "bgra32"optional | string | Pixel format string (default: "bgra32") Supported formats: |
Uint8Array — null if was an error (for example, bitmap in unsupported format or unsupported format specified)
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);
}
InvertColours()
Inverts the colours in a bitmap, to create a negative image. i.e. White becomes black, black becomes white, etc.
ReleaseGraphics(gr)
| Name | Type | Description |
|---|---|---|
gr | GdiGraphics |
Resize(w, h, mode)
| Name | Type | Description |
|---|---|---|
w | number | |
h | number | |
mode = 0optional | number |
RotateFlip(mode)
Changes will be saved in the current bitmap.
| Name | Type | Description |
|---|---|---|
mode | number | See RotateFlipType |
SaveAs(path, format)
| Name | Type | Description |
|---|---|---|
path | string | Full path including file extension. The parent folder must already exist. |
format = 'image/png'optional | string | "image/png" |
booleanlet img = utils.GetAlbumArtEmbedded(fb.GetFocusItem().RawPath, 0);
if (img) {
img.SaveAs("D:\\export.jpg", "image/jpeg");
}
StackBlur(radius)
Changes will be saved in the current bitmap.
| Name | Type | Description |
|---|---|---|
radius | number | Valid values 2-254. |
<caption>Blur image<caption>
// `samples/basic/StackBlur (image).js`<caption>Blur text<caption>
// `samples/basic/StackBlur (text).js`