decode-dxt
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/decode-dxt package

1.0.1 • Public • Published

decode-dxt

Decoder for the DXT texture formats.

Features

  • Supports Block Compression 1, 2 and 3 (DXT1-5)
  • Works in node and in browsers with Typed Array support

Example

An example using decode-dxt with parse-dds to decode the first mipmap texture of a DDS file using a DXT format.

var decodeDXT = require('decode-dxt'),
    parseDDS = require('parse-dds');
 
// parse the dds
var ddsBuffer = new Uint8Array(... DDS file ...),
    ddsData = parseDDS(ddsBuffer);
 
// get the first mipmap texture
var image = ddsData.images[0],
    imageWidth = image.shape[0],
    imageHeight = image.shape[1],
    imageDataView = new DataView(ddsBuffer.buffer, image.offset, image.length);
 
// convert the DXT texture to an Uint8Array containing RGBA data
var rgbaData = decodeDXT(imageDataView, imageWidth, imageHeight, ddsData.format);

Public API

Method

decode(imageDataView, imageWidth, imageHeight[, format = 'dxt1'])

Decode a given DXT image to an Uint8Array containing the RGBA data of the image.

  • imageDataView : A DataView pointing directly to the data of the DXT image.
  • imageWidth: The width of the image.
  • imageHeight: The height of the image.
  • format: The format of the image (dxt1, dxt2, dxt3, dxt4 or dxt5), default to dxt1.

Format flags

decode.dxt1, decode.dxt2, decode.dxt3, decode.dxt4 and decode.dxt5

Changelog

1.0.1 (2017-12-01) :

  • Fix black artifacts in some edge cases for BC2 and BC3.

1.0.0 (2016-08-06) :

  • First publication.

License

MIT

Package Sidebar

Install

npm i decode-dxt

Weekly Downloads

14

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kchapelier