wip
now does a check for dupe blocks on luma16 rendering (no dither) sometimes no decimation is needed on the sample vid but most of the time it will need decimation from 300-500ish down to 128 + any reverse video variants
This commit is contained in:
parent
8172650c8f
commit
a6e3e28057
1 changed files with 35 additions and 3 deletions
38
index.html
38
index.html
|
@ -24,6 +24,9 @@
|
||||||
<div>
|
<div>
|
||||||
<canvas id="work" width="80" height="160" class="stretchy"></canvas>
|
<canvas id="work" width="80" height="160" class="stretchy"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<span id="block-count">n/a</span> blocks per frame
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
let width = 80;
|
let width = 80;
|
||||||
|
@ -77,11 +80,40 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let blocks = [];
|
let blocks = [];
|
||||||
for (let y = 0; y < height / blockHeight; y++) {
|
let chars = new Uint16Array(widthBlocks * heightBlocks);
|
||||||
for (let x = 0; x < width / blockWidth; x++) {
|
for (let n = 0, y = 0; y < heightBlocks; y++) {
|
||||||
let i = y * (width / blockWidth) + x;
|
for (let x = 0; x < widthBlocks; x++, n++) {
|
||||||
|
let i = y * widthBlocks + x;
|
||||||
|
blocks[i] = new Uint8Array(blockWidth * blockHeight);
|
||||||
|
chars[n] = i;
|
||||||
|
for (let yy = 0; yy < blockHeight; yy++) {
|
||||||
|
for (let xx = 0; xx < blockWidth; xx++) {
|
||||||
|
let ii = yy * blockWidth + xx;
|
||||||
|
blocks[i][ii] = pixels[(y * blockHeight + yy) * width + (x * blockWidth + xx)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we have 800 blocks for 80x160 image
|
||||||
|
// But we can only use 128 + their mirror images
|
||||||
|
//
|
||||||
|
// First pass: sort.
|
||||||
|
let zero = "0".charCodeAt(0);
|
||||||
|
// Convert the 4bpp pixel indices into hex strings
|
||||||
|
let blockMap = {};
|
||||||
|
let keys = [];
|
||||||
|
for (let i = 0; i < blocks.length; i++) {
|
||||||
|
let key = blocks[i].map((n) => n.toString(16)).join('');
|
||||||
|
console.log(key);
|
||||||
|
if (!blockMap[key]) {
|
||||||
|
blockMap[key] = blocks[i];
|
||||||
|
keys.push(blockMap[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let span = document.querySelector('#block-count');
|
||||||
|
span.textContent = `${keys.length}`;
|
||||||
|
|
||||||
|
|
||||||
for (let y = 0; y < height; y++) {
|
for (let y = 0; y < height; y++) {
|
||||||
for (let x = 0; x < width; x++) {
|
for (let x = 0; x < width; x++) {
|
||||||
|
|
Loading…
Reference in a new issue