Package Exports
- bmp-js-browser
- bmp-js-browser/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bmp-js-browser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bmp-js-browser
在浏览器环境中解码并预览 bmp 图片
npm 链接
https://www.npmjs.com/package/bmp-js-browser
安装
npm install bmp-js-browser --save使用
import BmpJs from 'bmp-js-browser';
const src = '你的 bmp 图片地址';
fetch(src).then(async (res) => {
const arrayBuffer = await res.arrayBuffer();
const canvas = document.createElement('canvas');
const imageData = decode(arrayBuffer);
canvas.width = imageData.width;
canvas.height = imageData.height;
const ctx = canvas.getContext('2d');
ctx.putImageData(imageData, 0, 0);
document.body.appendChild(canvas);
});