-
Notifications
You must be signed in to change notification settings - Fork 4
/
picture-codec.ts
31 lines (26 loc) · 1.05 KB
/
picture-codec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Window, Picture, ResourceSource, App, Byo2ImageCreation, Byo2ImageDataType, Byo2Image } from "../../../src";
import { getControlDemoContainer } from "../utility";
import * as fs from "fs";
import * as path from "path";
export function main(window: Window, { app }: { app: App }) {
//
const codec = app.GetImageCodec();
const buffer = fs.readFileSync(path.resolve(__dirname, "./Paste#6.png"));
const source = ResourceSource.FromBuffer(buffer);
const aveImage = codec.Open(source);
//
const imgcp = new Byo2ImageCreation();
imgcp.DataType = Byo2ImageDataType.Raw;
const imgData = aveImage.GetImage(0, 0, 0);
imgcp.Data = ResourceSource.FromArrayBuffer(imgData.Data, imgData.RowPitch, imgData.SlicePitch);
imgcp.Width = imgData.Width;
imgcp.Height = imgData.Height;
imgcp.Format = imgData.Format;
const byo2 = new Byo2Image(window, imgcp);
//
const picture = new Picture(window);
picture.SetImage(byo2);
const container = getControlDemoContainer(window, 1, 300, 300);
container.ControlAdd(picture).SetGrid(1, 1);
window.SetContent(container);
}