diff --git a/sd_to_hd.py b/sd_to_hd.py new file mode 100755 index 0000000..1f7c0d0 --- /dev/null +++ b/sd_to_hd.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import blup.frame +import blup.animation +import writebml +import sys + +if len(sys.argv) != 3: + print('usage: %s INFILE OUTFILE' % (sys.argv[0]), file=sys.stderr) + sys.exit(1) +infname = sys.argv[1] +outfname = sys.argv[2] + +anim = blup.animation.load(infname) + +dim = blup.frame.FrameDimension(22, 16, 256, 3) +newanim = blup.animation.Animation(dim) + +for f in anim: + newf = blup.animation.AnimationFrame(dim, f.delay) + for x in range(f.dimension.width): + for y in range(f.dimension.height): + newf.setPixel(x + 2, y*2, tuple(map(lambda x: int((x/anim.dimension.depth)*dim.depth), f.getPixel(x, y)))) + newf.setPixel(x + 2, y*2 + 1, tuple(map(lambda x: int((x/anim.dimension.depth)*dim.depth), f.getPixel(x, y)))) + newanim.addFrame(newf) + +writebml.writeBml(newanim, outfname) +