1.0.0 • Published 6 years ago
gen-jsbmp v1.0.0
gen-jsbmp
a javascript lib to generate different depth of bmp image
how to use
install
npm i -S gen-jsbmp
commonjs
const jsbmp = require('gen-jsbmp')
in browser
<script src = "jsbmp.js">
es2015
import jsbmp from 'gen-jsbmp'
API
var bmp_base64 = jsmap(canvas, depth)
- canvas: The original picture container
- depth: The depth of bmp image, can be one of 1,2,4,8,16,24,32. Default to be 1.
example
var depthArr = [1, 2, 4, 8, 16, 24, 32]
var canvas = document.createElement('canvas')
var img = new Image()
img.src = 'test.png'
img.onload = function () {
canvas.width = img.width, canvas.height = img.height
var ctx = canvas.getContext('2d')
ctx.drawImage(img, 0, 0)
depthArr.forEach(function(depth) {
var img = new Image()
document.body.appendChild(img)
img.src = jsbmp(canvas, depth)
})
}
1.0.0
6 years ago