How to convert a bitmap with javascript to an imag

2019-07-27 13:36发布

I am building an Electron app. There is a need to have a color picker so I want to build an eye-drop style color picker. I got some hints that robot.js and paper.js might be helpful so I checked them. I'd like to, kind of, combine them together. I use robot.js to get the screen capture with a format of

bitmap {
  width: 2560,
  height: 1600,
  byteWidth: 10240,
  bitsPerPixel: 32,
  bytesPerPixel: 4,
  image: <Buffer d0 d0 cd ff d0 d0 cd ff d0 d0 cd ff d0 d0 cd ff d0 d0 cd ff d0 d0 cd ff d0 d0 cd ff d0 cf cd ff cf cf cd ff cf cf cd ff cf cf cd ff cf cf cd ff cf cf ... >,
  colorAt: [Function] }

I'd like to display this bitmap as an image (maybe with a HTML img tag). Then I will be able to build a Raster (paper.js) for the eye drop and mouse event listening.

enter image description here

However, I did not find a way to convert this image buffer to an actual image.

Any help is appreciate!

登录 后发表回答