Esempio n. 1
0
void initialize_settings (void)
{
  _fgcolor = colortrans(WHITE);	//Default drawing color = white
  _bgcolor = colortrans(BLACK);	//default background = black
  _fontcolor = WHITE;				/* Default font color */
  putenv("LIBGRAPHICS_ACTIVE=1");  /*This is used by text funtions to 
				     determine whether to use stdout or 
				     drawing screen */
  setfontcolor(_fontcolor); //Loads the default font -- white
  _internal_linestyle.linestyle = SOLID_LINE;
  _internal_linestyle.thickness = NORM_WIDTH;
  _internal_linestyle.upattern = 0xffff;
}
static int
cresp(		/* transform color according to matrix */
	COLOR	cout,
	COLOR	cin
)
{
	colortrans(cout, solmat, cin);
	return(clipgamut(cout, bright(cout), CGAMUT, colmin, colmax));
}
Esempio n. 3
0
static void
matscan(			/* apply color matrix to scaline */
	register COLOR	*sl,
	int	len,
	COLORMAT	mat
)
{
	while (len--) {
		colortrans(sl[0], mat, sl[0]);
		clipgamut(sl[0], greypoint(sl[0]), CGAMUT, cblack, cwhite);
		sl++;
	}
}
static void
xyY2RGB(		/* convert xyY to RGB */
	COLOR	rgbout,
	register float	xyYin[3]
)
{
	COLOR	ctmp;
	double	d;

	d = xyYin[2] / xyYin[1];
	ctmp[0] = xyYin[0] * d;
	ctmp[1] = xyYin[2];
	ctmp[2] = (1. - xyYin[0] - xyYin[1]) * d;
				/* allow negative values */
	colortrans(rgbout, xyz2rgbmat, ctmp);
}
Esempio n. 5
0
static void
mbscan(			/* apply macbethcal adj. to scaline */
	COLOR	*sl,
	int	len,
	register struct mbc	*mb
)
{
	double	d;
	register int	i, j;

	while (len--) {
		colortrans(sl[0], mb->cmat, sl[0]);
		clipgamut(sl[0], greypoint(sl[0]), CGAMUT, mb->cmin, mb->cmax);
		for (i = 0; i < 3; i++) {
			d = colval(sl[0],i);
			for (j = 0; j < 4 && mb->xa[i][j+1] <= d; j++)
				;
			colval(sl[0],i) = ( (mb->xa[i][j+1] - d)*mb->ya[i][j] +
					(d - mb->xa[i][j])*mb->ya[i][j+1] ) /
					(mb->xa[i][j+1] - mb->xa[i][j]);
		}
		sl++;
	}
}
static void
clrdebug(void)			/* put out debug picture from color input */
{
	static COLR	blkclr = BLKCOLR;
	COLR	mbclr[24], cvclr[24], orclr[24];
	COLR	*scan;
	COLOR	ctmp, ct2;
	int	y, i;
	register int	x, rg;
						/* convert colors */
	for (i = 0; i < 24; i++) {
		copycolor(ctmp, mbRGB[i]);
		clipgamut(ctmp, bright(ctmp), CGAMUT, cblack, cwhite);
		setcolr(mbclr[i], colval(ctmp,RED),
				colval(ctmp,GRN), colval(ctmp,BLU));
		if (inpflags & 1L<<i) {
			copycolor(ctmp, inpRGB[i]);
			clipgamut(ctmp, bright(ctmp), CGAMUT, cblack, cwhite);
			setcolr(orclr[i], colval(ctmp,RED),
					colval(ctmp,GRN), colval(ctmp,BLU));
			if (rawmap)
				copycolr(cvclr[i], mbclr[i]);
			else {
				bresp(ctmp, inpRGB[i]);
				colortrans(ct2, solmat, ctmp);
				clipgamut(ct2, bright(ct2), CGAMUT,
						cblack, cwhite);
				setcolr(cvclr[i], colval(ct2,RED),
						colval(ct2,GRN),
						colval(ct2,BLU));
			}
		}
	}
						/* allocate scanline */
	scan = (COLR *)malloc(xmax*sizeof(COLR));
	if (scan == NULL) {
		perror(progname);
		exit(1);
	}
						/* finish debug header */
	fputformat(COLRFMT, debugfp);
	putc('\n', debugfp);
	fprtresolu(xmax, ymax, debugfp);
						/* write debug picture */
	for (y = ymax-1; y >= 0; y--) {
		for (x = 0; x < xmax; x++) {
			rg = chartndx(x, y, &i);
			if (rg == RG_CENT) {
				if (!(1L<<i & gmtflags) || (x+y)&07)
					copycolr(scan[x], mbclr[i]);
				else
					copycolr(scan[x], blkclr);
			} else if (rg == RG_BORD || !(1L<<i & inpflags))
				copycolr(scan[x], blkclr);
			else if (rg == RG_ORIG)
				copycolr(scan[x], orclr[i]);
			else /* rg == RG_CORR */
				copycolr(scan[x], cvclr[i]);
		}
		if (fwritecolrs(scan, xmax, debugfp) < 0) {
			fprintf(stderr, "%s: error writing debugging picture\n",
					progname);
			exit(1);
		}
	}
						/* clean up */
	fclose(debugfp);
	free((void *)scan);
}