summaryrefslogtreecommitdiff
path: root/libdraw/computil.c
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 /libdraw/computil.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'libdraw/computil.c')
-rw-r--r--libdraw/computil.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libdraw/computil.c b/libdraw/computil.c
new file mode 100644
index 00000000..3ec103b8
--- /dev/null
+++ b/libdraw/computil.c
@@ -0,0 +1,37 @@
+#include "lib9.h"
+#include "draw.h"
+
+/*
+ * compressed data are seuences of byte codes.
+ * if the first byte b has the 0x80 bit set, the next (b^0x80)+1 bytes
+ * are data. otherwise, it's two bytes specifying a previous string to repeat.
+ */
+void
+_twiddlecompressed(uchar *buf, int n)
+{
+ uchar *ebuf;
+ int j, k, c;
+
+ ebuf = buf+n;
+ while(buf < ebuf){
+ c = *buf++;
+ if(c >= 128){
+ k = c-128+1;
+ for(j=0; j<k; j++, buf++)
+ *buf ^= 0xFF;
+ }else
+ buf++;
+ }
+}
+
+int
+_compblocksize(Rectangle r, int depth)
+{
+ int bpl;
+
+ bpl = bytesperline(r, depth);
+ bpl = 2*bpl; /* add plenty extra for blocking, etc. */
+ if(bpl < NCBLOCK)
+ return NCBLOCK;
+ return bpl;
+}