]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/mothra/getpix.c
merge
[plan9front.git] / sys / src / cmd / mothra / getpix.c
index 2979f5f94ba925b3689a6d2f22d02d1774ed22b6..d966de53c396e04b5250e60d458277ae7b0de7f5 100644 (file)
@@ -21,12 +21,6 @@ char *pixcmd[]={
 [BMP]  "bmp -9t",
 };
 
-void storebitmap(Rtext *t, Image *b){
-       t->b=b;
-       free(t->text);
-       t->text=0;
-}
-
 void getimage(Rtext *t, Www *w){
        int pfd[2];
        Action *ap;
@@ -40,8 +34,8 @@ void getimage(Rtext *t, Www *w){
        seturl(&url, ap->image, w->url->fullname);
        for(p=w->pix;p!=nil; p=p->next)
                if(strcmp(ap->image, p->name)==0 && ap->width==p->width && ap->height==p->height){
-                       storebitmap(t, p->b);
-                       w->changed=1;
+                       t->b = p->b;
+                       update(w);
                        return;
                }
        fd=urlopen(&url, GET, 0);
@@ -50,7 +44,7 @@ void getimage(Rtext *t, Www *w){
                snprint(err, sizeof(err), "[%s: %r]", url.fullname);
                free(t->text);
                t->text=strdup(err);
-               w->changed=1;
+               update(w);
                close(fd);
                return;
        }
@@ -87,8 +81,8 @@ void getimage(Rtext *t, Www *w){
        p->height=ap->height;
        p->next=w->pix;
        w->pix=p;
-       storebitmap(t, b);
-       w->changed=1;
+       t->b=b;
+       update(w);
 }
 
 void getpix(Rtext *t, Www *w){
@@ -144,8 +138,15 @@ void getpix(Rtext *t, Www *w){
        }
 }
 
-void freepix(void *p)
-{
+ulong countpix(void *p){
+       ulong n=0;
+       Pix *x;
+       for(x = p; x; x = x->next)
+               n += Dy(x->b->r)*bytesperline(x->b->r, x->b->depth);
+       return n;
+}
+
+void freepix(void *p){
        Pix *x, *xx;
        xx = p;
        while(x = xx){