Socket
Book a DemoInstallSign in
Socket

parse-dds

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-dds

parses the headers of a DDS texture file

1.0.0
Source
npmnpm
Version published
Weekly downloads
330
-46.69%
Maintainers
1
Weekly downloads
 
Created
Source

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:

  • DXT1 (RGB)
  • DXT3 (RGBA)
  • DXT5 (RGBA)

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:

  • shape an array representing the [ width, height ] of the texture
  • flags the DDS bit flags stored in the file
  • format a string, either 'dxt1', 'dxt3' or 'dxt5'
  • images a list of information to extract sub-arrays for each mipmap level

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
}

License

MIT, see LICENSE.md for details.

Keywords

dds

FAQs

Package last updated on 25 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.