本文整理汇总了TypeScript中ijs.Image类的典型用法代码示例。如果您正苦于以下问题:TypeScript Image类的具体用法?TypeScript Image怎么用?TypeScript Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('fill alpha', () => {
const img = new Image(1, 2, { kind: ImageKind.RGBA });
img.fillAlpha(0);
expect(img.data).toStrictEqual(Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 0]));
img.fillAlpha(50);
expect(img.data).toStrictEqual(Uint8Array.from([0, 0, 0, 50, 0, 0, 0, 50]));
});
示例2: test
test('invert with out parameter set to self', () => {
const img = new Image(1, 2, {
kind: ImageKind.GREYA,
data: Uint8Array.from([0, 255, 255, 0])
});
img.invert({ out: img });
expect(img.data).toStrictEqual(Uint8Array.from([255, 0, 0, 255]));
});
示例3: it
it('should create from existing data array', () => {
// prettier-ignore
const data = Uint8Array.from([
0, 1, 2,
3, 4, 5
]);
const img = new Image(3, 2, { data, kind: ImageKind.GREY });
expect(img.getValue(1, 0, 0)).toBe(3);
expect(img.data).toBe(data);
});
示例4: test
test('split GREYA', () => {
const img = new Image(1, 2, {
kind: ImageKind.GREYA,
data: Uint8Array.from([0, 1, 254, 255])
});
const split = img.split();
expect(split).toHaveLength(2);
expect(split[0].data).toStrictEqual(Uint8Array.from([0, 254]));
expect(split[1].data).toStrictEqual(Uint8Array.from([1, 255]));
});
示例5: test
test('GREYA to GREY', () => {
const image = new Image({
width: 2,
height: 2,
data: new Uint8Array([10, 100, 30, 100, 50, 100, 70, 100]),
kind: ImageKind.GREYA
});
const converted = image.convertColor(ImageKind.GREY);
expect(converted.data).toStrictEqual(new Uint8Array([10, 30, 50, 70]));
});