Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/libdraw/cloadimage.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <draw.h>
4
 
5
int
6
cloadimage(Image *i, Rectangle r, uchar *data, int ndata)
7
{
8
	int m, nb, miny, maxy, ncblock;
9
	uchar *a;
10
 
11
	if(!rectinrect(r, i->r)){
12
		werrstr("cloadimage: bad rectangle");
13
		return -1;
14
	}
15
 
16
	miny = r.min.y;
17
	m = 0;
18
	ncblock = _compblocksize(r, i->depth);
19
	while(miny != r.max.y){
20
		maxy = atoi((char*)data+0*12);
21
		nb = atoi((char*)data+1*12);
22
		if(maxy<=miny || r.max.y<maxy){
23
			werrstr("creadimage: bad maxy %d", maxy);
24
			return -1;
25
		}
26
		data += 2*12;
27
		ndata -= 2*12;
28
		m += 2*12;
29
		if(nb<=0 || ncblock<nb || nb>ndata){
30
			werrstr("creadimage: bad count %d", nb);
31
			return -1;
32
		}
33
		a = bufimage(i->display, 21+nb);
34
		if(a == nil)
35
			return -1;
36
		a[0] = 'Y';
37
		BPLONG(a+1, i->id);
38
		BPLONG(a+5, r.min.x);
39
		BPLONG(a+9, miny);
40
		BPLONG(a+13, r.max.x);
41
		BPLONG(a+17, maxy);
42
		memmove(a+21, data, nb);
43
		miny = maxy;
44
		data += nb;
45
		ndata += nb;
46
		m += nb;
47
	}
48
	return m;
49
}