本文整理匯總了TypeScript中test.readImage函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript readImage函數的具體用法?TypeScript readImage怎麽用?TypeScript readImage使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了readImage函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('auto decode png', async () => {
const buffer = readImage('grey8.png');
expect(() => decode(buffer)).not.toThrow();
const decoded = decode(buffer);
expect(decoded.depth).toStrictEqual(ColorDepth.UINT8);
expect(decoded.kind).toStrictEqual(ImageKind.GREY);
});
示例2: it
it('should encode what it decoded', () => {
const buffer = readImage('grey8.png');
const img = decode(buffer);
const imgDup = decode(encodePng(img));
expect(imgDup.kind).toStrictEqual(img.kind);
expect(imgDup.depth).toStrictEqual(img.depth);
expect(imgDup.data).toStrictEqual(img.data);
});
示例3: async
it.each(tests)('should load from buffer %s', async (name) => {
const buffer = readImage(`${name}.jpg`);
const img = await decodeJpeg(buffer);
expect(img.kind).toBe(ImageKind.RGBA);
expect(img.depth).toBe(ColorDepth.UINT8);
});
示例4: async
it.each(tests)('should load from buffer %s', async (name, depth, kind) => {
const buffer = readImage(`${name}.png`);
const img = decodePng(buffer);
expect(img.depth).toBe(depth);
expect(img.kind).toBe(kind);
});