parse-dds

unstable

Parses DDS texture headers in Node and the browser.

This was adapted from @toji's wonderful webgl-texture-utils.

Currently this only supports a limited range of common DDS formats:

See test/index.js for an example in Node, or demo/index.js for a WebGL compressed texture example.

Pull requests welcome.

Example

var parse = require('parse-dds')

var buffer = new Uint8Array(... DDS file ...)
var dds = parse(buffer)

console.log(dds.format)  // 'dxt1'
console.log(dds.shape)   // [ width, height ]
console.log(dds.images)  // [ ... mipmap level data ... ]

// get the compressed texture data for gl.compressedTexImage2D
var image = dds.images[0]
var texture = new Uint8Array(buffer, image.offset, image.length)

Install

npm install parse-dds --save-dev

Usage

NPM

dds = parse(arrayBuffer)

Parses an ArrayBuffer and returns the DDS headers for that file.

The returned values:

Each image has the form:

{
  shape: [ width, height ], // size of this mipmap level
  offset: x,                // byte offset into the input buffer
  length: len,              // length of this mipmap level image data
}

See Also

License

MIT, see LICENSE.md for details.