rsc | 324891a | 2006-06-25 18:58:06 +0000 | [diff] [blame] | 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 | } |