mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
encoder no alpha option
This commit is contained in:
@@ -212,17 +212,6 @@ for (let blockX = 0; blockX < Math.ceil(imgw / 4.0); blockX++) {
|
||||
let cocg4 = readByte()
|
||||
let y4 = readShort()
|
||||
|
||||
if (blockX == 0 && blockY == 0) {
|
||||
serial.println(`cocg: ${(cocg1 & 15).toString(16)} ${((cocg1 >>> 4) & 15).toString(16)}`)
|
||||
serial.println(`y: ${y1.toString(16)}`)
|
||||
serial.println(`cocg: ${cocg2.toString(16)}`)
|
||||
serial.println(`y: ${y2.toString(16)}`)
|
||||
serial.println(`cocg: ${cocg3.toString(16)}`)
|
||||
serial.println(`y: ${y3.toString(16)}`)
|
||||
serial.println(`cocg: ${cocg4.toString(16)}`)
|
||||
serial.println(`y: ${y4.toString(16)}`)
|
||||
}
|
||||
|
||||
let a1 = 65535; let a2 = 65535; let a3 = 65535; let a4 = 65535
|
||||
|
||||
if (hasAlpha) {
|
||||
|
||||
@@ -73,11 +73,11 @@ Image is divided into 4x4 blocks and each block is serialised, then the entire f
|
||||
*/
|
||||
|
||||
if (!exec_args[2]) {
|
||||
printerrln("Usage: encodeipf input.jpg output.ipf")
|
||||
printerrln("Usage: encodeipf input.jpg output.ipf [/noalpha]")
|
||||
return 1
|
||||
}
|
||||
|
||||
let configUseAlpha = true
|
||||
let configUseAlpha = !(exec_args[3].toLowerCase() == "/noalpha")
|
||||
|
||||
filesystem.open("A", exec_args[1], "R")
|
||||
|
||||
@@ -104,6 +104,33 @@ println(`Dim: ${imgw}x${imgh}, channels: ${channels}, Has alpha: ${hasAlpha}`)
|
||||
let writeCount = 0
|
||||
let writeBuf = sys.malloc(blockSize * ((hasAlpha) ? 20 : 12))
|
||||
|
||||
let bayerKernels = [
|
||||
[
|
||||
0,8,2,10,
|
||||
12,4,14,6,
|
||||
3,11,1,9,
|
||||
15,7,13,5,
|
||||
],
|
||||
[
|
||||
8,2,10,0,
|
||||
4,14,6,12,
|
||||
11,1,9,3,
|
||||
7,13,5,15,
|
||||
],
|
||||
[
|
||||
7,13,5,15,
|
||||
8,2,10,0,
|
||||
4,14,6,12,
|
||||
11,1,9,3,
|
||||
],
|
||||
[
|
||||
15,7,13,5,
|
||||
0,8,2,10,
|
||||
12,4,14,6,
|
||||
3,11,1,9,
|
||||
]
|
||||
].map(it => { it.map(it => { (it + 0.5) / 16 }) })
|
||||
|
||||
function chromaToFourBits(f) {
|
||||
let r = Math.round(f * 8) + 7
|
||||
return (r < 0) ? 0 : (r > 15) ? 15 : r
|
||||
|
||||
Reference in New Issue
Block a user