6 unloadimage(Image *i, Rectangle r, uchar *data, int ndata)
12 if(!rectinrect(r, i->r)){
13 werrstr("unloadimage: bad rectangle");
16 bpl = bytesperline(r, i->depth);
17 if(ndata < bpl*Dy(r)){
18 werrstr("unloadimage: buffer too small");
23 flushimage(d, 0); /* make sure subsequent flush is for us only */
25 while(r.min.y < r.max.y){
26 a = bufimage(d, 1+4+4*4);
28 werrstr("unloadimage: %r");
33 werrstr("unloadimage: image too wide");
42 BPLONG(a+13, r.max.x);
43 BPLONG(a+17, r.min.y+dy);
44 if(flushimage(d, 0) < 0)
46 n = _displayrddraw(d, data+ntot, ndata-ntot);