tunload.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tunload.c (437B)
---
1 #include <u.h>
2 #include <libc.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(u32int);
22 data += l;
23 }
24 return ndata;
25 }