📄 out_scrn.c
字号:
dx_dy = 0L; /* Zero slope, leave xc alone */ goto skip_calc; } /* calculate dx_dy at 16.16 fixed point */dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);/* We have to check for a @#$%@# possible multiply overflow *//* by doing another @#$*& multiply. In assembly language, *//* the program could just check the OVerflow flag or whatever*//* works on the particular processor. This C code is meant *//* to be processor independant. */temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;/* This sees if the sign bits start at bit 15 *//* if they do, no overflow has occurred */temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);if ( (temp2 != (fix15)-1) && (temp2 != 0x0000) ) { /* Overflow. Pick point closest to yc + .5 */ if (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd)) { /* use x1 instead of x0 */ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); } goto skip_calc; }/* calculate new xc at the center of the *current* scan line *//* due to banding, yc may be several lines away from y0 *//* xc += (yc + .5 - y0) * dx_dy *//* This multiply generates a subpixel delta. *//* So we shift it to be a 16.16 delta */xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;skip_calc:yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */if (how_many_y < 0) { /* Vector down */ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */ while(yc >= how_many_y) { sp_add_intercept_screen(yc--,xc); xc -= dx_dy; } } else { /* Vector up */ /* check to see that line doesn't extend beyond top of band */ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists; while(yc != how_many_y) { sp_add_intercept_screen(yc++,xc); xc += dx_dy; } }}#endif#if INCL_SCREENFUNCTION void end_contour_screen()GDECL/* Called after the last vector in each contour */{#if DEBUGprintf("END_CONTOUR_SCREEN()\n");#endifsp_intercepts.inttype[sp_globals.next_offset-1] |= END_INT;}#endif#if INCL_SCREENFUNCTION boolean end_char_screen()GDECL/* Called when all character data has been output * Return TRUE if output process is complete * Return FALSE to repeat output of the transformed data beginning * with the first contour */{fix31 xorg;fix31 yorg;#if INCL_CLIPPINGfix31 em_max, em_min, bmap_max, bmap_min;#endif#if DEBUGprintf("END_CHAR_SCREEN()\n");#endifif (sp_globals.first_pass) { if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin) { sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift; } else { sp_globals.xmin = sp_globals.xmax = 0; } if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin) {#if INCL_CLIPPING switch(sp_globals.tcb0.xtype) { case 1: /* 180 degree rotation */ if (sp_globals.specs.flags & CLIP_TOP) { sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift; bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; sp_globals.clip_ymin = -1 * sp_globals.clip_ymin; if (bmap_min < sp_globals.clip_ymin) sp_globals.ymin = sp_globals.clip_ymin; else sp_globals.ymin = bmap_min; } if (sp_globals.specs.flags & CLIP_BOTTOM) { sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift; bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift; if (bmap_max < sp_globals.clip_ymax) sp_globals.ymax = bmap_max; else sp_globals.ymax = sp_globals.clip_ymax; } sp_globals.clip_xmax = -sp_globals.xmin; sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) - sp_globals.xmin; break; case 2: /* 90 degree rotation */ if (sp_globals.specs.flags & CLIP_TOP) { sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift; sp_globals.clip_xmin = -1 * sp_globals.clip_xmin; bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; if (bmap_min > sp_globals.clip_xmin) sp_globals.clip_xmin = bmap_min; /* normalize to x origin */ sp_globals.clip_xmin -= sp_globals.xmin; } if (sp_globals.specs.flags & CLIP_BOTTOM) { sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift; bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift; if (bmap_max < sp_globals.clip_xmax) sp_globals.xmax = bmap_max; else sp_globals.xmax = sp_globals.clip_xmax; sp_globals.clip_ymax = 0; if ((sp_globals.specs.flags & CLIP_TOP) && (sp_globals.ymax > sp_globals.clip_ymax)) sp_globals.ymax = sp_globals.clip_ymax; sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16); if ((sp_globals.specs.flags & CLIP_BOTTOM) && (sp_globals.ymin < sp_globals.clip_ymin)) sp_globals.ymin = sp_globals.clip_ymin; /* normalize to x origin */ sp_globals.clip_xmax -= sp_globals.xmin; } break; case 3: /* 270 degree rotation */ if (sp_globals.specs.flags & CLIP_TOP) { sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift; sp_globals.clip_xmin = -1 * sp_globals.clip_xmin; bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; /* let the minimum be the larger of these two values */ if (bmap_min > sp_globals.clip_xmin) sp_globals.clip_xmin = bmap_min; /* normalize the x value to new xorgin */ sp_globals.clip_xmin -= sp_globals.xmin; } if (sp_globals.specs.flags & CLIP_BOTTOM) { sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift; bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift; /* let the max be the lesser of these two values */ if (bmap_max < sp_globals.clip_xmax) { sp_globals.xmax = bmap_max; sp_globals.clip_xmax = bmap_max; } else sp_globals.xmax = sp_globals.clip_xmax; /* normalize the x value to new x origin */ sp_globals.clip_xmax -= sp_globals.xmin; } /* compute y clip values */ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16); if ((sp_globals.specs.flags & CLIP_TOP) && (sp_globals.ymax > sp_globals.clip_ymax)) sp_globals.ymax = sp_globals.clip_ymax; sp_globals.clip_ymin = 0; if ((sp_globals.specs.flags & CLIP_BOTTOM) && (sp_globals.ymin < sp_globals.clip_ymin)) sp_globals.ymin = sp_globals.clip_ymin; break; default: /* this is for zero degree rotation and arbitrary rotation */ if (sp_globals.specs.flags & CLIP_TOP) { sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift; bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift; if (bmap_max > sp_globals.clip_ymax) sp_globals.ymax = bmap_max; else sp_globals.ymax = sp_globals.clip_ymax; } if (sp_globals.specs.flags & CLIP_BOTTOM) { sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2)); sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift; sp_globals.clip_ymin = - sp_globals.clip_ymin; bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; if (bmap_min < sp_globals.clip_ymin) sp_globals.ymin = sp_globals.clip_ymin; else sp_globals.ymin = bmap_min; } sp_globals.clip_xmin = -sp_globals.xmin; sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) - sp_globals.xmin; break; }if ( !(sp_globals.specs.flags & CLIP_TOP))#endif sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;#if INCL_CLIPPINGif ( !(sp_globals.specs.flags & CLIP_BOTTOM))#endif sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift; } else { sp_globals.ymin = sp_globals.ymax = 0; } /* add in the rounded out part (from xform.) of the left edge */ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift)); else if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ; else xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift)); else if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)); else /* all other cases have no round error on yorg */ yorg = (fix31)sp_globals.ymin << 16; open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg, sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin); if (sp_globals.intercept_oflo) { sp_globals.y_band.band_min = sp_globals.ymin; sp_globals.y_band.band_max = sp_globals.ymax; init_intercepts_out(); sp_globals.first_pass = FALSE; sp_globals.extents_running = FALSE; return FALSE; } else { sp_proc_intercepts_screen(); close_bitmap(); return TRUE; } }else { if (sp_globals.intercept_oflo) { reduce_band_size_out(); init_intercepts_out(); return FALSE; } else { sp_proc_intercepts_screen(); if (next_band_out()) { init_intercepts_out(); return FALSE; } close_bitmap(); return TRUE; } }}#endif#if INCL_SCREENFUNCTION LOCAL void sp_add_intercept_screen(y, x)GDECLfix15 y; /* Y coordinate in relative pixel units */ /* (0 is lowest sample in band) */fix31 x; /* X coordinate of intercept in subpixel units *//* Called by line() to add an intercept to the intercept list structure */{register fix15 from; /* Insertion pointers for the linked list sort */register fix15 to;register fix15 xloc;register fix15 xfrac;#if DEBUGprintf(" Add intercept(%2d, %x)\n", y + sp_globals.y_band.band_min, x);/* Bounds checking IS done in debug mode */if (y < 0) /* Y value below bottom of current band? */ { printf(" Intecerpt less than 0!!!\007\n"); return; }if (y > (sp_globals.no_y_lists - 1)) /* Y value above top of current band? */ { printf(" Intercept too big for band!!!!!\007\n"); return; }#endif/* Store new values */sp_intercepts.car[sp_globals.next_offset] = xloc = (fix15)(x >> 16);sp_intercepts.inttype[sp_globals.next_offset] = sp_intercepts.leftedge | (xfrac = ((x >> 8) & FRACTION));/* Find slot to insert new element (between from and to) */from = y; /* Start at list head */while( (to = sp_intercepts.cdr[from]) != 0) /* Until to == end of list */ { if (xloc < sp_intercepts.car[to]) /* If next item is larger than or same as this one... */ goto insert_element; /* ... drop out and insert here */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -