8 typedef struct Pix Pix;
25 void getimage(Rtext *t, Www *w){
35 seturl(&url, ap->image, w->url->fullname);
36 for(p=w->pix;p!=nil; p=p->next)
37 if(strcmp(ap->image, p->name)==0 && ap->width==p->width && ap->height==p->height){
42 fd=urlopen(&url, GET, 0);
45 snprint(err, sizeof(err), "[%s: %r]", url.fullname);
53 if(typ < 0 || typ >= nelem(pixcmd) || pixcmd[typ] == nil){
54 werrstr("unknown image type");
57 if((fd = pipeline(pixcmd[typ], fd)) < 0)
59 if(ap->width>0 || ap->height>0){
64 p += sprint(p, "resize");
66 p += sprint(p, " -x %d", ap->width);
68 p += sprint(p, " -y %d", ap->height);
69 if((fd = pipeline(buf, fd)) < 0)
72 b=readimage(display, fd, 1);
74 werrstr("can't read image");
78 p = emallocz(sizeof(Pix), 1);
79 strncpy(p->name, ap->image, sizeof(p->name));
89 void getpix(Rtext *t, Www *w){
90 int i, pid, nworker, worker[NXPROC];
94 for(i=0; i<nelem(worker); i++)
100 pid = rfork(RFFDG|RFPROC|RFMEM);
103 fprint(2, "fork: %r\n");
109 for(i=0; i<nelem(worker); i++)
116 while(nworker == nelem(worker)){
117 if((pid = waitpid()) < 0)
119 for(i=0; i<nelem(worker); i++)
120 if(worker[i] == pid){
131 if((pid = waitpid()) < 0)
133 for(i=0; i<nelem(worker); i++)
134 if(worker[i] == pid){
142 ulong countpix(void *p){
145 for(x = p; x; x = x->next)
146 n += Dy(x->b->r)*bytesperline(x->b->r, x->b->depth);
150 void freepix(void *p){