mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
24 lines
640 B
JavaScript
24 lines
640 B
JavaScript
if (!exec_args[1]) {
|
|
printerrln("Usage: jpdectest image.jpg")
|
|
}
|
|
|
|
const fullFilePath = _G.shell.resolvePathInput(exec_args[1])
|
|
const file = files.open(fullFilePath.full)
|
|
const fileLen = file.size
|
|
const infile = sys.malloc(file.size); file.pread(infile, fileLen, 0)
|
|
|
|
//println("decoding")
|
|
|
|
// decode
|
|
const [imgw, imgh, channels, imageData] = graphics.decodeImageResample(infile, fileLen, -1, -1)
|
|
|
|
//println(`dim: ${imgw}x${imgh}`)
|
|
//println(`converting to displayable format...`)
|
|
|
|
// convert colour
|
|
graphics.setGraphicsMode(0)
|
|
graphics.imageToDisplayableFormat(imageData, -1048577, imgw, imgh, 4, 1)
|
|
|
|
sys.free(imageData)
|
|
sys.free(infile)
|