View | Details | Raw Unified | Return to bug 211077
Collapse All | Expand All

(-)pwcview.c (-6 / +12 lines)
Lines 58-63 Link Here
58
#define SCALE_NONE 0
58
#define SCALE_NONE 0
59
#define SCALE_DOUBLE 1
59
#define SCALE_DOUBLE 1
60
#define SCALE_FULL 2
60
#define SCALE_FULL 2
61
#define MAX_WIDTH 1600
62
#define MAX_HEIGHT 1200
63
61
int scale = SCALE_FULL;
64
int scale = SCALE_FULL;
62
65
63
#ifndef NOGUI
66
#ifndef NOGUI
Lines 865-871 Link Here
865
	}
868
	}
866
}
869
}
867
870
868
uint8_t motionmask[60][80];
871
uint8_t motionmask[MAX_HEIGHT/8][MAX_WIDTH/8];
869
int detectmotion(unsigned char *buf, int width, int height)
872
int detectmotion(unsigned char *buf, int width, int height)
870
{
873
{
871
	static int newbuf;
874
	static int newbuf;
Lines 1032-1039 Link Here
1032
		int ylast = (int)(event->button.y / divy);
1035
		int ylast = (int)(event->button.y / divy);
1033
		int x, y;
1036
		int x, y;
1034
1037
1035
		for(y = ystart ;y >= 0 && y < 60 && y <= ylast; y++)
1038
		for(y = ystart ;y >= 0 && y < MAX_HEIGHT/8 && y <= ylast; y++)
1036
			for(x = xstart; x >= 0 && x < 80 && x <= xlast; x++)
1039
			for(x = xstart; x >= 0 && x < MAX_WIDTH/8 && x <= xlast; x++)
1037
				motionmask[y][x] = (event->button.button == SDL_BUTTON_LEFT) ? 1 : 0;
1040
				motionmask[y][x] = (event->button.button == SDL_BUTTON_LEFT) ? 1 : 0;
1038
		xstart = ystart = -1;
1041
		xstart = ystart = -1;
1039
	}
1042
	}
Lines 1044-1049 Link Here
1044
#undef PSZ_MAX
1047
#undef PSZ_MAX
1045
#endif
1048
#endif
1046
#define PSZ_MAX 10
1049
#define PSZ_MAX 10
1050
/* with and heigt must be multible of 8*/
1051
1052
1047
struct {
1053
struct {
1048
	char *name;
1054
	char *name;
1049
	int width;
1055
	int width;
Lines 1271-1277 Link Here
1271
	}
1277
	}
1272
	
1278
	
1273
	if((fdmask = open("pwcview.msk",O_RDONLY)) != -1) {
1279
	if((fdmask = open("pwcview.msk",O_RDONLY)) != -1) {
1274
		read(fdmask,motionmask,60*80*sizeof(uint8_t));
1280
		read(fdmask,motionmask,MAX_WIDTH*MAX_HEIGHT/8/8*sizeof(uint8_t));
1275
		close(fdmask);
1281
		close(fdmask);
1276
		fprintf(stderr,"motion mask loaded\n");
1282
		fprintf(stderr,"motion mask loaded\n");
1277
	}
1283
	}
Lines 1432-1438 Link Here
1432
						break;
1438
						break;
1433
					case SDLK_w:
1439
					case SDLK_w:
1434
						if((fdmask = open("pwcview.msk",O_CREAT|O_TRUNC|O_WRONLY,0644)) != -1) {
1440
						if((fdmask = open("pwcview.msk",O_CREAT|O_TRUNC|O_WRONLY,0644)) != -1) {
1435
							write(fdmask,motionmask,60*80*sizeof(uint8_t));
1441
							write(fdmask,motionmask,MAX_WIDTH*MAX_HEIGHT/8/8*sizeof(uint8_t));
1436
							close(fdmask);
1442
							close(fdmask);
1437
							fprintf(stderr,"motion mask saved\n");
1443
							fprintf(stderr,"motion mask saved\n");
1438
						}
1444
						}
Lines 1483-1489 Link Here
1483
				else if(event.type == SDL_MOUSEBUTTONDOWN) {
1489
				else if(event.type == SDL_MOUSEBUTTONDOWN) {
1484
					if(showmask) {
1490
					if(showmask) {
1485
						if(event.button.button == SDL_BUTTON_MIDDLE) 
1491
						if(event.button.button == SDL_BUTTON_MIDDLE) 
1486
							memset(motionmask,0,60*80*sizeof(uint8_t));
1492
							memset(motionmask,0,MAX_WIDTH*MAX_HEIGHT/8/8*sizeof(uint8_t));
1487
						else
1493
						else
1488
							createmask(&event,&rect,vw.width,vw.height);
1494
							createmask(&event,&rect,vw.width,vw.height);
1489
					}
1495
					}

Return to bug 211077