summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-09-12 05:25:03 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-09-12 05:25:03 +0200
commitddbcb07ddf227ea7f454f5a3c407df88d2b688e2 (patch)
tree8bce733e2219d841c947139ac0b5feeab4818ca2
parent1e9e10b68e62160cd78cd729bcd8015a07a2f6e1 (diff)
npage: support .ps.gz files, better inferno bitmap detection
-rw-r--r--sys/src/cmd/npage.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/sys/src/cmd/npage.c b/sys/src/cmd/npage.c
index bb5b0d5db..5648cda6c 100644
--- a/sys/src/cmd/npage.c
+++ b/sys/src/cmd/npage.c
@@ -289,6 +289,22 @@ popenpdf(Page *p)
}
int
+infernobithdr(char *buf, int n)
+{
+ if(n >= 11){
+ if(memcmp(buf, "compressed\n", 11) == 0)
+ return 1;
+ if(strtochan((char*)buf))
+ return 1;
+ if(memcmp(buf, " ", 10) == 0 &&
+ '0' <= buf[10] && buf[10] <= '9' &&
+ buf[11] == ' ')
+ return 1;
+ }
+ return 0;
+}
+
+int
popengs(Page *p)
{
int n, i, pdf, ifd, ofd, pin[2], pout[2], pdat[2];
@@ -421,7 +437,7 @@ popengs(Page *p)
i = 0;
ofd = -1;
while((n = read(pdat[0], buf, sizeof(buf))) >= 0){
- if(ofd >= 0 && (n <= 0 || memcmp(buf, "compressed\n", 11) == 0)){
+ if(ofd >= 0 && (n <= 0 || infernobithdr(buf, n))){
snprint(nam, sizeof nam, "%d", i);
addpage(p, nam, popenconv, nil, ofd);
ofd = -1;
@@ -500,6 +516,10 @@ popenfile(Page *p)
p->data = "dvips -Pps -r0 -q1 -f1";
p->open = popengs;
}
+ else if(memcmp(buf, "\x1F\x8B", 2) == 0){
+ p->data = "gunzip";
+ p->open = popengs;
+ }
else if(memcmp(buf, "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1", 8) == 0){
p->data = "doc2ps";
p->open = popengs;
@@ -514,8 +534,6 @@ popenfile(Page *p)
p->data = "jpg -t9";
else if(memcmp(buf, "\211PNG\r\n\032\n", 3) == 0)
p->data = "png -t9";
- else if(memcmp(buf, "compressed\n", 11) == 0)
- p->data = nil;
else if(memcmp(buf, "\0PC Research, Inc", 17) == 0)
p->data = "aux/g3p9bit -g";
else if(memcmp(buf, "TYPE=ccitt-g31", 14) == 0)
@@ -528,11 +546,7 @@ popenfile(Page *p)
p->data = "ppm -t9";
else if(memcmp(buf, "BM", 2) == 0)
p->data = "bmp -t9";
- else if(memcmp(buf, " ", 10) == 0 &&
- '0' <= buf[10] && buf[10] <= '9' &&
- buf[11] == ' ')
- p->data = nil;
- else if(strtochan((char*)buf) != 0)
+ else if(infernobithdr(buf, n))
p->data = nil;
else {
werrstr("unknown image format");
@@ -793,7 +807,7 @@ zoomdraw(Image *d, Rectangle r, Rectangle top, Image *s, Point sp, int f)
sp.y++;
}
}
- sp = t->r.min;
+ sp = r.min;
for(x=r.min.x; x<r.max.x; x++){
gendrawdiff(d, Rect(x, r.min.y, x+1, r.max.y), top, t, sp, nil, ZP, S);
if(++a.x == f){