mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 01:07:18 +00:00
Easter egg (#123)
* lol zx quant * Adding ZX option * Improving colour selection so we don't end up with the same colour twice. Also fixing a bug with the colour conflict resolution. * Putting it behind a konami code * Better comments * Adding comment * Removing unnecessary malloc.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
<!doctype html>
|
||||
<style>
|
||||
canvas {
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
</style>
|
||||
<script src='imagequant.js'></script>
|
||||
<script>
|
||||
const Module = imagequant();
|
||||
@@ -23,6 +28,7 @@
|
||||
create_buffer: Module.cwrap('create_buffer', 'number', ['number', 'number']),
|
||||
destroy_buffer: Module.cwrap('destroy_buffer', '', ['number']),
|
||||
quantize: Module.cwrap('quantize', '', ['number', 'number', 'number', 'number', 'number']),
|
||||
zx_quantize: Module.cwrap('zx_quantize', '', ['number', 'number', 'number', 'number']),
|
||||
free_result: Module.cwrap('free_result', '', ['number']),
|
||||
get_result_pointer: Module.cwrap('get_result_pointer', 'number', []),
|
||||
};
|
||||
@@ -30,7 +36,9 @@
|
||||
const image = await loadImage('../example.png');
|
||||
const p = api.create_buffer(image.width, image.height);
|
||||
Module.HEAP8.set(image.data, p);
|
||||
api.quantize(p, image.width, image.height, 16, 1.0);
|
||||
//api.quantize(p, image.width, image.height, 256, 1.0);
|
||||
api.zx_quantize(p, image.width, image.height, 1);
|
||||
console.log('done');
|
||||
const resultPointer = api.get_result_pointer();
|
||||
const resultView = new Uint8Array(Module.HEAP8.buffer, resultPointer, image.width * image.height * 4);
|
||||
const result = new Uint8ClampedArray(resultView);
|
||||
|
||||
Reference in New Issue
Block a user