vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

unload.c (436B)


      1 #include "u.h"
      2 #include "lib.h"
      3 #include "draw.h"
      4 #include "memdraw.h"
      5 
      6 int
      7 _unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
      8 {
      9 	int y, l;
     10 	uchar *q;
     11 
     12 	if(!rectinrect(r, i->r))
     13 		return -1;
     14 	l = bytesperline(r, i->depth);
     15 	if(ndata < l*Dy(r))
     16 		return -1;
     17 	ndata = l*Dy(r);
     18 	q = byteaddr(i, r.min);
     19 	for(y=r.min.y; y<r.max.y; y++){
     20 		memmove(data, q, l);
     21 		q += i->width*sizeof(uint32);
     22 		data += l;
     23 	}
     24 	return ndata;
     25 }