ugo-formats
Advanced tools
Comparing version 1.0.0 to 1.1.0
/*! | ||
* ugo-formats.js v1.0.0 | ||
* ugo-formats.js v1.1.0 | ||
* 2018 James Daniel | ||
@@ -102,6 +102,7 @@ * Released under the MIT License | ||
this.fileHeader.setUint16(0, 0x424D); // "BM" file magic | ||
// using BITMAPINFOHEADER dib header variant: | ||
// using BITMAPV4HEADER dib header variant: | ||
this.dibHeader = new DataView(new ArrayBuffer(40)); | ||
this.dibHeader.setUint32(0, 40, true); | ||
this.dibHeader = new DataView(new ArrayBuffer(108)); | ||
this.dibHeader.setUint32(0, 108, true); // DIB header length | ||
this.dibHeader.setInt32(4, width, true); // width | ||
@@ -115,5 +116,5 @@ | ||
this.dibHeader.setUint32(16, 0, true); // compression method (0 = no compression) | ||
this.dibHeader.setUint32(16, 3, true); // compression method (3 = BI_BITFIELDS for rgba, 0 = no compression for 8 bit) | ||
this.dibHeader.setUint32(20, this.vWidth * this.height / bpp, true); // image data size, (width * height) / bits per pixel | ||
this.dibHeader.setUint32(20, this.vWidth * this.height / (bpp / 8), true); // image data size, (width * height) / bits per pixel | ||
@@ -124,7 +125,34 @@ this.dibHeader.setUint32(24, 3780, true); // x res, pixel per meter | ||
this.dibHeader.setUint32(32, 0, true); // the number of colors in the color palette, or 0 to default to 2n | ||
this.dibHeader.setUint32(32, 0, true); // the number of colors in the color palette, set by setPalette() method | ||
this.dibHeader.setUint32(36, 0, true); // he number of important colors used, or 0 when every color is important; generally ignored | ||
this.dibHeader.setUint32(36, 0, true); // the number of important colors used, or 0 when every color is important; generally ignored | ||
this.dibHeader.setUint32(40, 0x00FF0000, true); // red channel bitmask | ||
this.dibHeader.setUint32(44, 0x0000FF00, true); // green channel bitmask | ||
this.dibHeader.setUint32(48, 0x000000FF, true); // blue channel bitmask | ||
this.dibHeader.setUint32(52, 0xFF000000, true); // alpha channel bitmask | ||
this.dibHeader.setUint32(56, 0x206E6957, true); // LCS_WINDOWS_COLOR_SPACE, little-endian "Win " | ||
/// rest can be left as nulls | ||
}; | ||
BitmapRenderer.prototype.setFilelength = function setFilelength (value) { | ||
this.fileHeader.setUint32(2, value, true); | ||
}; | ||
BitmapRenderer.prototype.setPixelOffset = function setPixelOffset (value) { | ||
this.fileHeader.setUint32(10, value, true); | ||
}; | ||
BitmapRenderer.prototype.setCompression = function setCompression (value) { | ||
this.dibHeader.setUint32(16, value, true); | ||
}; | ||
BitmapRenderer.prototype.setPaletteCount = function setPaletteCount (value) { | ||
this.dibHeader.setUint32(32, value, true); | ||
}; | ||
BitmapRenderer.prototype.setPalette = function setPalette (paletteData) { | ||
@@ -138,2 +166,6 @@ var paletteLength = Math.pow(2, this.bpp); | ||
this.setPaletteCount(paletteLength); // set number of colors in DIB header | ||
this.setCompression(0); // set compression to 0 so we're not using 32 bit | ||
this.palette = palette; | ||
@@ -180,6 +212,4 @@ }; | ||
case 8: | ||
// set file length | ||
this.fileHeader.setUint32(2, headerByteLength + this.pixels.byteLength + this.palette.byteLength, true); // set pixel data offset | ||
this.fileHeader.setUint32(10, headerByteLength + this.palette.byteLength, true); | ||
this.setFilelength(headerByteLength + this.pixels.byteLength + this.palette.byteLength); | ||
this.setPixelOffset(headerByteLength + this.palette.byteLength); | ||
sections = sections.concat([this.palette.buffer, this.pixels.buffer]); | ||
@@ -190,6 +220,4 @@ break; | ||
case 32: | ||
// set file length | ||
this.fileHeader.setUint32(2, headerByteLength + this.pixels.byteLength, true); // set pixel data offset | ||
this.fileHeader.setUint32(10, headerByteLength, true); | ||
this.setFilelength(headerByteLength + this.pixels.byteLength); | ||
this.setPixelOffset(headerByteLength); | ||
sections = sections.concat([this.pixels.buffer]); | ||
@@ -196,0 +224,0 @@ break; |
{ | ||
"name": "ugo-formats", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "JavaScript API for parsing and rendering the proprietary image and menu formats used by Flipnote Hatena", | ||
@@ -5,0 +5,0 @@ "main": "dist/ugo-formats.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25759
424