diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libdraw/computil.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libdraw/computil.c')
-rwxr-xr-x | sys/src/libdraw/computil.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/src/libdraw/computil.c b/sys/src/libdraw/computil.c new file mode 100755 index 000000000..30a3d11e6 --- /dev/null +++ b/sys/src/libdraw/computil.c @@ -0,0 +1,38 @@ +#include <u.h> +#include <libc.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; +} |