/* constuct subpath with moveto and repeated lineto from Points */ int construct_path(struct line_pnts *Points, double shift, int t) { int i, np, k = 1; double *xarray, *yarray, x, y; np = Points->n_points; xarray = Points->x; yarray = Points->y; for (i = 0; i < np; i++) { x = XCONV(xarray[0] + shift); y = YCONV(yarray[0]); fprintf(PS.fp, "%.1f %.1f ", x, y); if (i == 0 && (t == START_PATH || t == WHOLE_PATH)) { fprintf(PS.fp, "M "); } else { fprintf(PS.fp, "LN "); } if (k == 2) { fprintf(PS.fp, "\n"); k = 0; } else { fprintf(PS.fp, " "); k++; } xarray++; yarray++; } if (t == CLOSE_PATH || t == WHOLE_PATH) { fprintf(PS.fp, "CP\n"); } return 1; }
/* * S E P A R A T E * * Unpack RGB byte tripples into three separate arrays of integers. * The first and last pixels are replicated twice, to handle border effects. * * Updated version: the outputs are Y U V values, not R G B. */ void separate(register int *rop, register int *gop, register int *bop, register unsigned char *cp, long int num) /* Y */ /* U */ /* V */ { register long int i; register int r, g, b; r = cp[0]; g = cp[1]; b = cp[2]; #define YCONV(_r, _g, _b) (_r * 0.299 + _g * 0.587 + _b * 0.144 + 0.9) #define UCONV(_r, _g, _b) (_r * -0.1686 + _g * -0.3311 + _b * 0.4997 + 0.9) #define VCONV(_r, _g, _b) (_r * 0.4998 + _g * -0.4185 + _b * -0.0813 + 0.9) rop[-1] = rop[-2] = YCONV(r, g, b); gop[-1] = gop[-2] = UCONV(r, g, b); bop[-1] = bop[-2] = VCONV(r, g, b); for ( i = num-1; i >= 0; i-- ) { r = cp[0]; g = cp[1]; b = cp[2]; cp += 3; *rop++ = YCONV(r, g, b); *gop++ = UCONV(r, g, b); *bop++ = VCONV(r, g, b); } r = cp[-3]; g = cp[-2]; b = cp[-1]; *rop++ = YCONV(r, g, b); *gop++ = UCONV(r, g, b); *bop++ = VCONV(r, g, b); *rop++ = YCONV(r, g, b); *gop++ = UCONV(r, g, b); *bop++ = VCONV(r, g, b); }