From bebeb6932f655a4cedb0f72eb0c985c94ea14ea6 Mon Sep 17 00:00:00 2001 From: Frederic Date: Mon, 26 Dec 2016 18:45:46 +0100 Subject: [PATCH] added sd_to_hd.py --- sd_to_hd.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 sd_to_hd.py 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) +