Esempio n. 1
0
static Errcode mask_move_cels(Pframedat *pfd)

/* ccb.cel a goes to mask 0 ccb.celb goes to mask non 0 */
{
int y;
Pixel *bline, *bgetbuf;
Rcel *bcel;
Coor width;
Coor bx, bwidth;
Errcode err = Success;

	width = pfd->dest->width;
	pfd->aline = pfd->lbuf;
	pfd->dline = pfd->aline + width;

	if(ccb.fcelb->flags & FCEL_XFORMED)
	{
		err = raster_transform(ccb.fcelb->rc,pfd->dest,&ccb.fcelb->xf,
								put_celsline, pfd, 0 );
		goto OUT;
	}

	bline = pfd->dline + width;
	bcel = ccb.fcelb->rc;
	bx = bcel->x;
	bgetbuf = bline;
	bwidth = width;


	if(bx)
	{
		clear_mem(bline,sizeof(Pixel)*width);
		if(bx > 0) /* smaller than dest */
		{
			bgetbuf += bx;
			bx = 0;
			bwidth = ccb.fcelb->flif.hdr.width;
		}
		else /* bigger than dest */
			bx = -bx;
	}

	for(y = 0; y < pfd->dest->height;++y)
	{
		if(y < bcel->y || y >= (bcel->y + bcel->height))
			clear_mem(bline,sizeof(Pixel)*width);
		else
			pj_get_hseg(bcel,bgetbuf,bx,y - bcel->y,bwidth);
		if((err = put_celsline(pfd,bline,0,y,width)) < Success)
			break;
	}
OUT:
	return(errend_abort_atom(err));
}
Esempio n. 2
0
static Errcode copy_fcel(Flicel *cel, Rcel *screen, Celcfit *cfit, int clearc)

/* if cel raster and screen are  the same will do nothing clearc of -2 will
 * make it use the old cfit if cfit is present */
{
Pldat pld;
Rcel *rc;
Errcode err = Success;

	start_abort_atom();

	if((rc = cel->rc) == screen)
		goto done;

	pld.xlat = NULL;
	if(cfit == NULL)
	{
		if(!cmaps_same(rc->cmap,screen->cmap))
		{
			pj_cmap_copy(rc->cmap,screen->cmap);
			if(screen == vb.pencel)
				see_cmap();
		}
	}
	else if( clearc == -2
			 || make_simple_cfit(rc->cmap, screen->cmap, cfit, clearc))
	{
		pld.xlat = cfit->ctable;
	}

	if(cel->flags & FCEL_XFORMED)
	{
		pld.dest = screen;
		err = raster_transform(rc,screen,&cel->xf,putxlat_line, &pld, 0 );
	}
	else
	{
		if(pld.xlat)
		{
			xlatblit(rc,0,0,screen,rc->x,rc->y,
					 rc->width,rc->height,pld.xlat);
		}
		else
		{
			pj_blitrect(rc,0,0,screen,rc->x,rc->y,
					 rc->width,rc->height);
		}
	}
done:
	return(errend_abort_atom(err));
}
Esempio n. 3
0
int main (int argc, const char *argv[]) {
	
	int c;
	int ok;
	
	char *infile, *morphfile, *outfile, *format, *input_layer, *output_layer;
	char *attrs, *spatial_filter, *attr_filter;
	int raster, back_transform;
	
	extern int optind;
	extern int optopt;
	extern char * optarg;
	
	
	if (argc < 2) {
		printUsage();
		return(0);
	}
	
	
	// Provide default values.
	infile = morphfile = outfile = input_layer = NULL;
	attrs = spatial_filter = attr_filter = NULL;
	format = NULL;
	raster = 0;
	output_layer = "transformed_layer";
	back_transform = 0;
	
	
	// Process command line
	while (1) {
		static struct option long_options[] =
		{
			{"help",			no_argument,		0,	'h'},
			{"input",			required_argument,	0,	'i'},
			{"morphfile",		required_argument,	0,	'm'},
			{"output",			required_argument,	0,	'o'},
			{"format",			required_argument,	0,	'f'},
			{"raster",			no_argument,		0,	'r'},
			{"input_layer",		required_argument,	0,	'1'},
			{"spatial_filter",	required_argument,	0,  's'},
			{"attr_filter",		required_argument,	0,	'w'},
			{"output_layer",	required_argument,  0,  '2'},
			{"attrs",			required_argument,	0,	'a'},
			{"back",			no_argument,		0,	'b'},
			{0, 0, 0, 0}
		};
		
		c = getopt_long(argc, (char**)argv, "hi:m:o:f:r1:s:w:a:2:b", long_options, NULL);
		if (c == -1) {
			break;
		}
		
		switch (c) {
			case 'h':
				printUsage();
				return 0;
			case 'i':
				infile = optarg;
				break;
			case 'o':
				outfile = optarg;
				break;
			case 'm':
				morphfile = optarg;
				break;
			case 'f':
				format = optarg;
				break;
			case '1':
				input_layer = optarg;
				break;
			case 's':
				spatial_filter = optarg;
				break;
			case 'a':
				attrs = optarg;
				break;
			case 'w':
				attr_filter = optarg;
				break;
			case '2':
				output_layer = optarg;
				break;
			case 'r':
				raster = 1;
				break;
			case 'b':
				back_transform = 1;
				break;
			case '?':
				return 1;
			default:
				printUsage();
				abort();
		}
	}
	
	
	// Input value checking.
	if (morphfile == NULL) {
		fprintf(stderr, "Error. You must supply a morph file.\n");
		exit(1);
	}
	if ((infile == NULL && outfile != NULL) || (infile != NULL && outfile == NULL)) {
		fprintf(stderr, "Error. Specify an input and an output file.\n");
		exit(1);
	}
	
	
	
	// Call the appropriate function for transforming the input layer.
	
	// If input and output files are not given, read the coordinates from standard input and
	// write the transformed values to the standard output.
	if (infile == NULL && outfile == NULL) {
		ok = coord_transform(morphfile, back_transform);
		return ok;
	}
	
	printf("r.morph.transform starting\n");
	
	// We have input and output files. Choose between raster and vector.
	if (raster) {
		ok = raster_transform(infile, morphfile, outfile, format, back_transform);
	} else {
		ok = vector_transform(infile, input_layer, spatial_filter, attr_filter, 
							  morphfile, 
							  outfile, attrs, format, output_layer, 
							  back_transform);
	}

	printf("r.morph.transform done\n");
	
	return ok;
}