summaryrefslogtreecommitdiff
path: root/appl/grid/jpg2bit.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/grid/jpg2bit.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/grid/jpg2bit.b')
-rw-r--r--appl/grid/jpg2bit.b47
1 files changed, 47 insertions, 0 deletions
diff --git a/appl/grid/jpg2bit.b b/appl/grid/jpg2bit.b
new file mode 100644
index 00000000..9c452edd
--- /dev/null
+++ b/appl/grid/jpg2bit.b
@@ -0,0 +1,47 @@
+implement jpg2bit;
+
+include "sys.m";
+ sys : Sys;
+
+include "draw.m";
+ draw: Draw;
+ Context, Display, Point, Rect, Image, Screen, Font: import draw;
+
+include "grid/readjpg.m";
+ readjpg: Readjpg;
+
+display : ref draw->Display;
+screen : ref draw->Screen;
+context : ref draw->Context;
+
+jpg2bit : module {
+ init : fn (ctxt : ref Draw->Context, argv : list of string);
+};
+
+init(ctxt : ref Draw->Context, argv : list of string)
+{
+ display = ctxt.display;
+ screen = ctxt.screen;
+ context = ctxt;
+
+ sys = load Sys Sys->PATH;
+ readjpg = load Readjpg Readjpg->PATH;
+ readjpg->init(display);
+
+ draw = load Draw Draw->PATH;
+ argv = tl argv;
+ if (argv == nil) exit;
+ filename := hd argv;
+ filename2 : string;
+ if (tl argv == nil) {
+ if (len filename > 3) filename2 = filename[:len filename - 4];
+ filename2 += ".bit";
+ }
+ else filename2 = hd tl argv;
+ img := readjpg->jpg2img(hd argv, "", chan of string, nil);
+ fd := sys->create(filename2, sys->OWRITE,8r666);
+ if (fd != nil)
+ display.writeimage(fd,img);
+
+}
+