LensStudio:Ui.Pixmap
ClassRepresents an image in memory.
Index
Properties
Methods
Example
export class PixmapPanel extends PanelPlugin {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.UiPixmapExample';
d.name = 'Pixmap Example';
d.defaultDockState = DockState.Detached;
d.defaultSize = new Size(350, 300);
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
createWidget(parent: Widget): Widget {
const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
root.layout = layout;
const title = new Label(root);
title.text = 'Pixmap Demo';
title.fontRole = FontRole.TitleBold;
layout.addWidget(title);
// Pixmap holds a pixel image for UI display
const pixmap = new Pixmap(new Editor.Path('icon.png'));
pixmap.resize(64, 64);
const info = new Label(root);
info.text = 'Pixmap size: ' + pixmap.width + 'x' + pixmap.height;
layout.addWidget(info);
// Display the pixmap in an ImageView
const imageView = new ImageView(root);
imageView.pixmap = pixmap;
imageView.scaledContents = true;
imageView.setFixedWidth(64);
imageView.setFixedHeight(64);
layout.addWidget(imageView);
return root;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
}
}
Extends
Constructors
Constructor
new Pixmap(
filename):Pixmap
Constructs a new Pixmap instance for use in UI widgets.
Parameters
| Parameter | Type |
|---|---|
filename | Path |
Returns
Pixmap
Overrides
ScriptObject.constructor
Properties
aspectRatioMode
aspectRatioMode:
AspectRatioMode
Controls how the aspect ratio is preserved during resize operations.
height
height:
number
Height of the pixmap in pixels.
transformationMode
transformationMode:
TransformationMode
Controls the transformation quality mode used when scaling the pixmap.
width
width:
number
Width of the pixmap in pixels.
Methods
crop()
crop(
rect):void
Crops the pixmap to the specified rectangle.
Parameters
| Parameter | Type |
|---|---|
rect | Rect |
Returns
void
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
load()
load(
filename):void
Loads an image from the given file path.
Parameters
| Parameter | Type |
|---|---|
filename | Path |
Returns
void
resize()
resize(
width,height):void
Resizes the pixmap to the specified width and height.
Parameters
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns
void
save()
save(
filename,quality?):void
Saves the pixmap to the given file path, with optional quality setting.
Parameters
| Parameter | Type |
|---|---|
filename | Path |
quality? | number |
Returns
void