From 8eb19bdc7feb84d318f0b6f11f9f808125362a6f Mon Sep 17 00:00:00 2001 From: Catamine <kirsa@riseup.net> Date: Thu, 28 Jul 2022 18:26:58 -0400 Subject: [PATCH] initial commit --- tools/image.pbm | Bin 0 -> 251 bytes tools/pbm.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tools/image.pbm create mode 100755 tools/pbm.py diff --git a/tools/image.pbm b/tools/image.pbm new file mode 100644 index 0000000000000000000000000000000000000000..b4003000b3a981536cfe6fb70949ad69cb3d5ef0 GIT binary patch literal 251 zcmWGA;W9KdQ!q5+YGC}pen6hVfSvgd`}sct4Ga&M8~7L)*cgAX_rEA$U~ph$U}0cj zVEDky|KLLdhy}(4jO+(L9QeW9$j2fhz`$U@z})=d!w=?mJ{cPW1_OZujO`yD{$S*1 zu`&3NV8H<9erS+ms8IY+V8hVB!2aRk!vod~FPI-x)G#nOuzz@X_(6H&4fh8>>KGXk z*gqU(f56@#kq_cF6fl2ikpIAbK%)NPhdRa|^~@jI?0+yn;Hdxnpx*IAJ^P3L`ak?1 h4FCUs`2YFO|Lh<3|A&B&AnN!B5DCJ+LB#tHTmY@Fb#4Fv literal 0 HcmV?d00001 diff --git a/tools/pbm.py b/tools/pbm.py new file mode 100755 index 0000000..7fefdcf --- /dev/null +++ b/tools/pbm.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys +import os + +def main(): + if len(sys.argv) != 2: + usage() + return 2 + + with open(sys.argv[1], 'rb') as fd: + pbm_format = fd.readline().strip() + if pbm_format != b'P4': + print("ERROR: input file must be binary PBM (type P4)", + file = sys.stderr) + return 1 + pbm_dims = [int(d) for d in fd.readline().strip().split()] + pbm_data = fd.read() + + fbbase = "fb_{0}".format(os.path.basename(sys.argv[1])) + fbname = os.path.splitext(fbbase)[0] + with sys.stdout as fd: + f = "{0} = framebuf.FrameBuffer(bytearray({1}), {2}, {3}, framebuf.MONO_HLSB)\n" + fd.write(f.format(fbname, str(pbm_data), pbm_dims[0], pbm_dims[1])) + + +def usage(): + print("""usage: {0} PBM_FILE""".format(os.path.basename(sys.argv[0])), + file = sys.stderr) + +if __name__ == '__main__': + main() \ No newline at end of file -- GitLab