bitmap-js icon indicating copy to clipboard operation
bitmap-js copied to clipboard

feature request: read bitmap file from ArrayBuffer, for browsers

Open trusktr opened this issue 6 years ago • 0 comments

I'm perusing for tools to read bitmap file content, and stumbled on this. Neat!

In the web, reading a bitmap file can yield an ArrayBuffer with the binary data, like this:

const response = await fetch('/path/to/file.bmp')
const data = response.arrayBuffer()

I've no experience with bitmaps (other than starting to peruse how to read the data just now). I've tried steps in this guide with no luck: https://www.i-programmer.info/projects/36-web/6234-reading-a-bmp-file-in-javascript.html

But when I send the data to the GPU (WebGL), I get a black texture, so I'm doing something wrong somewhere.

Anyway, it'd be neat if this lib would detect a browser environment, and in that case either accept an ArrayBuffer object, or a URL and fetch it to an ArrayBuffer, and finally create the same sort of meta object with the same content (but ArrayBuffers or UInt8Arrays inside the object instead of Buffers).

trusktr avatar Nov 02 '19 17:11 trusktr