本文整理匯總了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]));
});