This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
240 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
��"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f��"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"���"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f��"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"���"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f��"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"���"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f��"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"�"f��"f��"f��"f����"���"���"���"� |
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
Binary file not shown.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2015 Yahoo! Inc. | ||
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms. | ||
|
||
describe('Decode', function () { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2015 Yahoo! Inc. | ||
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms. | ||
|
||
describe('Encode', function () { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2015 Yahoo! Inc. | ||
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms. | ||
|
||
describe('PNG', function () { | ||
|
||
require('./utils'); | ||
|
||
require('./decode'); | ||
require('./encode'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
var expect = require('chai').expect; | ||
|
||
var fs = require('fs'); | ||
|
||
module.exports = { | ||
|
||
/** | ||
* @class tests | ||
* @method addTests | ||
* @param {object} options | ||
* @param {string} options.resourceGroup | ||
* @param {string} options.resourceFile | ||
* @param {string[]} [options.chunkTypes] | ||
* @param {boolean} [options.imageCheck=false] | ||
* @param {boolean} [options.headerCheck=false] | ||
* @param {int} [options.width=32] | ||
* @param {int} [options.height=32] | ||
* @param {int} [options.bitDepth=8] | ||
* @param {int} [options.colorType=0] | ||
* @param {int} [options.filter=0] | ||
* @param {int} [options.compression=0] | ||
* @param {int} [options.interlace=0] | ||
*/ | ||
addTests: function (options) { | ||
|
||
before(function () { | ||
this.file = this.resource(options.resourceGroup, options.resourceFile + '.png'); | ||
}); | ||
|
||
it('should decode', function () { | ||
this.decode(this.file); | ||
}); | ||
|
||
it('should have mandatory chunks', function () { | ||
expect(this.chunks).to.contain.keys('IDAT', 'IHDR', 'IEND'); | ||
}); | ||
|
||
if (options.chunkTypes) { | ||
it('should have chunks', function () { | ||
expect(this.chunks).to.contain.keys(options.chunkTypes); | ||
}); | ||
} | ||
|
||
if (options.imageCheck) { | ||
it('should load the image buffer', function () { | ||
|
||
var pathRaw = this.resource(options.resourceGroup, options.resourceFile + '.raw'), | ||
pathPng = this.resource(options.resourceGroup, options.resourceFile + '_trueColor.png'); | ||
|
||
if (!fs.existsSync(pathRaw)) { | ||
|
||
fs.writeFileSync(pathRaw, this.image); | ||
this.encode(pathPng, this.image, options.width, options.height); | ||
|
||
throw new Error('Compare-to image did not exist. Please check manually the image and check it in.'); | ||
} | ||
|
||
this.compareToFile(this.image, pathRaw); | ||
}); | ||
} | ||
|
||
describe('Data', function () { | ||
|
||
it('should have volatile data', function () { | ||
if (options.headerCheck) { | ||
expect(this.data).to.contain.key('volatile'); | ||
} | ||
}); | ||
|
||
if (options.headerCheck) { | ||
|
||
describe('Header', function () { | ||
|
||
before(function () { | ||
expect(this.data.volatile.header).to.be.not.undefined; | ||
this.header = this.data.volatile.header; | ||
}); | ||
|
||
it('should have the right resolution', function () { | ||
expect(this.header.width).to.be.equal(options.width || 32); | ||
expect(this.header.height).to.be.equal(options.height || 32); | ||
}); | ||
|
||
if (options.bitDepth !== undefined) { | ||
it('should have the correct bit-depth', function () { | ||
expect(this.header.bitDepth).to.be.equal(options.bitDepth); | ||
}); | ||
} | ||
|
||
if (options.colorType !== undefined) { | ||
it('should have the correct color-type', function () { | ||
expect(this.header.colorType).to.be.equal(options.colorType); | ||
}); | ||
} | ||
|
||
if (options.filter !== undefined) { | ||
it('should have the correct filter method', function () { | ||
expect(this.header.filter).to.be.equal(options.filter); | ||
}); | ||
} | ||
|
||
if (options.compression !== undefined) { | ||
it('should have the correct compression method', function () { | ||
expect(this.header.compression).to.be.equal(options.compression); | ||
}); | ||
} | ||
|
||
if (options.interlace !== undefined) { | ||
it('should have the correct interlace method', function () { | ||
expect(this.header.interlace).to.be.equal(options.interlace); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2015 Yahoo! Inc. | ||
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms. | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var Decoder = require('../../index').Decoder; | ||
var Encoder = require('../../index').Encoder; | ||
|
||
before(function () { | ||
|
||
this.resource = function (groups, file) { | ||
|
||
groups = [].concat(groups); | ||
|
||
var completePath = path.join(__dirname, 'PngSuite'); | ||
|
||
groups.forEach(function (group) { | ||
completePath = path.join(completePath, group); | ||
}); | ||
|
||
completePath = path.join(completePath, file); | ||
|
||
return completePath; | ||
}; | ||
|
||
this.decode = function (path) { | ||
|
||
this.blob = fs.readFileSync(path); | ||
|
||
this.decoder = new Decoder(); | ||
|
||
this.image = this.decoder.decode(this.blob, { strict: true }); | ||
this.data = this.decoder.getChunkData(); | ||
this.chunks = this.decoder.getChunks(); | ||
}; | ||
|
||
this.encode = function (path, buffer, width, height) { | ||
|
||
this.encoder = new Encoder(); | ||
|
||
this.encodedBlob = this.encoder.encode(buffer, width, height); | ||
|
||
fs.writeFileSync(path, this.encodedBlob); | ||
}; | ||
|
||
this.compareToFile = function (buffer, path) { | ||
|
||
var compareToBuffer = fs.readFileSync(path); | ||
|
||
if (compareToBuffer.length != buffer.length) { | ||
throw new Error('Buffer have different sizes.'); | ||
} | ||
|
||
for(var i = 0; i < buffer.length; i++) { | ||
if (buffer[i] != compareToBuffer[i]) { | ||
throw new Error('Buffers are different.'); | ||
} | ||
} | ||
} | ||
}); |