Example #1
0
static void
ra2ps(void)				/* convert Radiance scanlines to 6-bit */
{
	register COLR	*scanin;
	int	y;
						/* allocate scanline */
	scanin = (COLR *)malloc(xmax*sizeof(COLR));
	if (scanin == NULL)
		quiterr("out of memory in ra2ps");
						/* convert image */
	for (y = ymax-1; y >= 0; y--) {
		if (freadcolrs(scanin, xmax, stdin) < 0)
			quiterr("error reading Radiance picture");
		if (putprim == Cputprim || devgam != 1.) {
			if (bradj)			/* adjust exposure */
				shiftcolrs(scanin, xmax, bradj);
			colrs_gambs(scanin, xmax);	/* gamma compression */
		} else
			normcolrs(scanin, xmax, bradj);
		if (docolor) {
			(*putprim)(scanin, RED);
			(*putprim)(scanin, GRN);
			(*putprim)(scanin, BLU);
		} else
			(*putprim)(scanin, GRY);
		if (ferror(stdout))
			quiterr("error writing PostScript file");
	}
	putchar('\n');
						/* free scanline */
	free((void *)scanin);
}
Example #2
0
static void
getrow(			/* get the specified row from our image */
	int  y
)
{
	if (y == currow)
		return;
	if (y < currow) {
		fseek(stdin, picstart, 0);
		currow = -1;
	}
	do
		if (freadcolrs(scanln, xmax, stdin) < 0) {
			fprintf(stderr, "%s: error reading picture (y==%d)\n",
					progname, ymax-1-y);
			exit(1);
		}
	while (++currow < y);
	if (bradj)
		shiftcolrs(scanln, xmax, bradj);
	colrs_gambs(scanln, xmax);
	if (pixscan != NULL) {
		if (samplefac)
			neu_dith_colrs(pixscan, scanln, xmax);
		else
			dith_colrs(pixscan, scanln, xmax);
	}
}
Example #3
0
static void
ra2ppm(	/* convert Radiance picture to 1-byte/sample Pixmap */
	int  binary,
	int  grey
)
{
	COLR	*scanin;
	register int	x;
	int	y;
						/* allocate scanline */
	scanin = (COLR *)malloc(xmax*sizeof(COLR));
	if (scanin == NULL)
		quiterr("out of memory in ra2ppm");
						/* convert image */
	for (y = ymax-1; y >= 0; y--) {
		if (freadcolrs(scanin, xmax, stdin) < 0)
			quiterr("error reading Radiance picture");
		if (bradj)
			shiftcolrs(scanin, xmax, bradj);
		for (x = grey?xmax:0; x--; )
			scanin[x][GRN] = normbright(scanin[x]);
		colrs_gambs(scanin, xmax);
		if (grey)
			if (binary)
				for (x = 0; x < xmax; x++)
					putc(scanin[x][GRN], stdout);
			else
				for (x = 0; x < xmax; x++)
					printf("%d\n", scanin[x][GRN]);
		else
			if (binary)
				for (x = 0; x < xmax; x++) {
					putc(scanin[x][RED], stdout);
					putc(scanin[x][GRN], stdout);
					putc(scanin[x][BLU], stdout);
				}
			else
				for (x = 0; x < xmax; x++)
					printf("%d %d %d\n", scanin[x][RED],
							scanin[x][GRN],
							scanin[x][BLU]);
		if (ferror(stdout))
			quiterr("error writing Pixmap");
	}
						/* free scanline */
	free((void *)scanin);
}