📄 xlc_codegen.c
字号:
if (dll_font_table [i] .dll_active == ACTIVE) { dispose_delete_box_from_cache (i); } } while (stack_ptr < PAGE) { M$SAVE(); } ps_str (str_scale); ps_str (str_next_line);}/* * * wipe_spacing * */wipe_spacing (){ WORD i; M$CLOSE_ALL(); ps_str (str_next_line); while (stack_ptr > (SPACED_LEVEL - 1)) { M$RESTORE(); } invalidate_spaced_font_cache (); while (stack_ptr < PAGE) { M$SAVE(); } ps_str (str_scale); ps_str (str_next_line);}/* * * output_sixel_in_hex * */output_sixel_in_hex ( ahp, avp, im_hor_grid, sf_hor_grid, vert_grid, byte_cnt, sf_byte_cnt, sixel_buff )UBYTE sixel_buff [];LONG ahp, avp, sf_byte_cnt, byte_cnt, sf_hor_grid, im_hor_grid, vert_grid;{register UBYTE *sbuff_ptr, /* Sixel buffer pointer */ hex_buff, /* One hex byte of converted data */ vert_mask; /* Bit mask for sixel bites */register LONG bitwidth, /* Total number of bits in a */ /* row = byte_cnt * 8 */ alpha,i,j,k; /* Misc. variables */ if (byte_cnt > 0) { bitwidth = byte_cnt << 3; /* scale the unit square, so that PS can draw the picture */ /* remember that we work in an inverted scale in y, so we need */ /* to invert in y by multiplying the y scale by -1 */ /* As we are always using this invertedd axis, (Both in Portrait & */ /* Landscape) there is no need to ask whether we should, as by the time */ /* we output the sixels (here), orientation has already been set. */ scalex = ((float)im_hor_grid / (float)cur_ps_st -> scale_factor.xval); if (ABS(scalex) < 1) scalex = 1; scaley = ((float)vert_grid / (float)cur_ps_st -> scale_factor.yval); if (ABS(scaley) < 1) scaley = 1; sprintf (str_buffer,"%f %f%s",scalex,scaley,str_float_scale); ps_str (str_buffer);/* if (! cg_st.cgst_first_row) ps_str (str_sixel_new_line); */ ps_str (str_sixel_data_hex);/* In hex output mode, use HEX output, and short records so VMS does not mess up our output file*/ vert_mask = 1; for (i = 0; i < 6; i ++) { sbuff_ptr = &sixel_buff[0]; for (k = 0; k <= bitwidth ; k += 512) /* Note that the above number (512) is arbitrary ** it is just there to include a CR/LF every now ** and then so we don't end up with "record too long" ** 512 seems like a good number, it is 64 bytes, ** or 128 HEX chars. Fits neatly on the screen, ** and in a record */ { alpha = MIN (512, bitwidth - k); for (j = 0; j < alpha; j += 4) { hex_buff = (*(sbuff_ptr++) & vert_mask) ? 0 : 8; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 4; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 2; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 1; /* Output the object */ /* ps_char (hexbuff) */ /* expand ps_schar slightly here */ /* but leave the processing of funnies to */ /* dispose of char by including them in the */ /* exclusion above */ /* * Stuff the character into the output buffer */ *obuf_ptr++ = (hex_buff < 10 ) ? (hex_buff + '0') : (hex_buff + 'A' - 10); /* * Check for a buffer overflow or buffer full */ M$CHECK_BUFF_OF() ; } ps_str (str_next_line); } vert_mask <<= 1; } byte_cnt = 0; old_bitwidth = bitwidth; cg_st.cgst_first_row = FALSE; }}/* * * output_sixel_in_bin * */output_sixel_in_bin ( ahp, avp, im_hor_grid, sf_hor_grid, vert_grid, byte_cnt, sf_byte_cnt, sixel_buff )UBYTE sixel_buff [];LONG ahp, avp, sf_byte_cnt, byte_cnt, sf_hor_grid, im_hor_grid, vert_grid; {register UBYTE *sbuff_ptr, /* Sixel buffer pointer */ hex_buff, /* One hex byte of converted data */ vert_mask; /* Bit mask for sixel bites */register LONG bitwidth, /* Total number of bits in a */ /* row = byte_cnt * 8 */ alpha,i,j,k; /* Misc. variables */ if (byte_cnt > 0) { bitwidth = byte_cnt << 3; /* scale the unit square, so that PS can draw the picture */ /* remember that we work in an inverted scale in y, so we need */ /* to invert in y by multiplying the y scale by -1 */ /* As we are always using this invertedd axis, (Both in Portrait & */ /* Landscape) there is no need to ask whether we should, as by the time */ /* we output the sixels (here), orientation has already been set. */ scalex = ((float)im_hor_grid / (float)cur_ps_st -> scale_factor.xval); if (ABS(scalex) < 1) scalex = 1; scaley = ((float)vert_grid / (float)cur_ps_st -> scale_factor.yval); if (ABS(scaley) < 1) scaley = 1; sprintf (str_buffer,"%f %f%s",scalex,scaley,str_float_scale); ps_str (str_buffer);/* if (! cg_st.cgst_first_row) ps_str (str_sixel_new_line); */ ps_str (str_sixel_data_bin);/* In binary mode, so we go faster*/ vert_mask = 1; for (i = 0; i < 6; i ++) { sbuff_ptr = &sixel_buff[0]; for (k = 0; k <= bitwidth ; k += 512) /* Note that the above number (512) is arbitrary ** it is just there to include a CR/LF every now ** and then so we don't end up with "record too long" ** 512 seems like a good number, it is 64 bytes, ** or 128 HEX chars. Fits neatly on the screen, ** and in a record */ { alpha = MIN (512, bitwidth - k); for (j = 0; j < alpha; j += 8) { hex_buff = (*(sbuff_ptr++) & vert_mask) ? 0 : 128; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 64; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 32; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 16; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 8; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 4; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 2; if (!(*(sbuff_ptr++) & vert_mask)) hex_buff |= 1; /* Output the object */ /* ps_char (hexbuff) */ /* expand ps_schar slightly here */ /* but leave the processing of funnies to */ /* dispose of char by including them in the */ /* exclusion above */ /* * Stuff the character into the output buffer */ *obuf_ptr++ = (hex_buff ); /* * Check for a buffer overflow or buffer full */ M$CHECK_BUFF_OF() ; } } vert_mask <<= 1; } byte_cnt = 0; old_bitwidth = bitwidth; cg_st.cgst_first_row = FALSE; }}/* * * output_sixel_as_font * */output_sixel_as_font ( ahp, avp, im_hor_grid, sf_hor_grid, vert_grid, byte_cnt, sf_byte_cnt, sixel_buff )/******************************************************************This routine was derived in structure from previously existingroutines output_sixel_in_hex() and output_sixel_in_bin().General structure and interface to the rest of the translator have been maintained, but the fundamental approach of sixel_fonthas caused some internal changes.This routine maps from a sixel character and its count to a set ofcharacters that, in the sixel_font, are expressed as a singlecharacter in a PostScript string and 'show' command.See routine init_sixel_font_keys() for the use of six_rptr[]and sixel_cmprss_mppng[]. 5.23.1 Generalities This prints one row of sixel data to the postscript machine. In the process it will convert the sixels into a text string to be output mapped through a special dot-matrix font for output. 5.23.2 Input 1. sixel_buffer 2. sixel_count 3. margins 5.23.3 Output 1. data as a PostScript string and 'show' command 5.23.4 Called Routines 1. oprintf 5.23.5 Internal Variables And Storage 5.23.6 Code Comments******************************************************************/UBYTE sixel_buff [];LONG ahp, avp, sf_byte_cnt, byte_cnt, sf_hor_grid, im_hor_grid, vert_grid; {register UBYTE sx_ent, /* temporary storage for sixel entry */ *sbuff_ptr, /* Sixel buffer pointer */ hex_buff, /* One hex byte of converted data */ vert_mask; /* Bit mask for sixel bites */register LONG bitwidth, /* old replacement for byte_cnt */ countdown, /* byte_cnt countdown */ rpt_cnt, /* character repeat count */ wrap_cnt, /* counter for character wrap */ i,j,k; /* Misc. variables */ if (sf_byte_cnt > 0) { countdown = sf_byte_cnt; /* save initial byte_cnt for counting down row */ /* remember that we work in an inverted scale in y, so we need */ /* to invert in y by multiplying the y scale by -1 */ /* As we are always using this invertedd axis, (Both in Portrait & */ /* Landscape) there is no need to ask whether we should, as by the time */ /* we output the sixels (here), orientation has already been set. */ scalex = ( 6.0 * (float)sf_hor_grid ) / (float)cur_ps_st -> scale_factor.xval; if (ABS(scalex) < 1) scalex = 1; /* vert_grid is 6*hor_grid in gr_nl; same here to maintain aspect ratio */ scaley = -((float)vert_grid / (float)cur_ps_st -> scale_factor.yval); if (ABS(scaley) < 1) scaley = -1; /* negated to invert sixel writing direction (was upside down); probably will require a new translate value as well */ if ( ( (float)((int)scalex) == scalex ) && ( (float)((int)scaley) == scaley ) ) /* this reduces excess trailing zeros */ sprintf (str_buffer, "%d %d %s", (int)scalex, (int)scaley, str_float_scale); else sprintf (str_buffer, "%f %f %s", scalex, scaley, str_float_scale); ps_str (str_buffer); ps_str ( str_save ); /* do save/restore at this (the sixel band) level */ ps_str ( str_sixelfontfind ); /* select the sixel font */ ps_str ( str_open_show ); /* open paren for string */ wrap_cnt = 1; /* start wrap counter */ sbuff_ptr = &sixel_buff[0]; while ( countdown > 0 ) /* go through the whole buffer */ { rpt_cnt = 0; /* repeat count is for current character */ sx_ent = *sbuff_ptr; /* copy the current character */ /* while successive characters are the same and there are more characters to follow... */ while ( ( sx_ent == *sbuff_ptr ) && ( countdown > 0 ) ) { *sbuff_ptr++; /* ...up the pointer to next character */ rpt_cnt++; /* up the repeat count for this character */ countdown--; /* decrement the saved byte count */ } /* after the loop, rpt_cnt has repeat count for current character */ /* is this character compressible? (has equiv and needs it?) */ if ( ( six_rptr[sx_ent]->rpt_val != 0 ) && ( rpt_cnt > 1 ) ) /* yes, process through equivalence list, be ready to fall out into non-repeat handler to take care of residual count */ { i = 0; /* scan through sixel repeater table for compression mappings */ while ( ( six_rptr[sx_ent][i].rpt_val != 0 ) && ( rpt_cnt > 1 ) ) { /* while the current mapping character is useful... */ while ( six_rptr[sx_ent][i].rpt_val <= rpt_cnt ) { /* ...use it... */ ps_schar( six_rptr[sx_ent][i].char_mapped ); /* ...and account for it by reducing the repeat count */ rpt_cnt -= six_rptr[sx_ent][i].rpt_val; wrap_cnt++; /* increment the wrap counter */ if ( ( six_rptr[sx_ent][i].char_mapped == '\\' ) || ( six_rptr[sx_ent][i].char_mapped == '(' ) || ( six_rptr[sx_ent][i].char_mapped == ')' ) ) wrap_cnt++; /* if a backslash was used, up counter again */ if ( wrap_cnt > 72 ) /* do a line break if needed */ { ps_char( '\n' ); wrap_cnt = 0; } } /* end while (application of current compression count) */ i++; /* increment ptr to next repeat equivalence key */ } /* end while (search for applicable compression counts */ } /* end if (compressible character) then... */ /* this loop outputs the current sixel-equivalent character its repeat count times, and also outputs the remainder of the characters needed to fulfill the repeat count for compressibles; most often this will be the last value needed to fill out an odd repeat count, as the smallest repeat mapping is for a count of two */ for ( i=0 ; i<rpt_cnt ; i++ ) { ps_schar( sx_ent+63 ); /* output the sixel character */ if ( sx_ent+63 == '\\' ) wrap_cnt++; /* the only special sixel character */ if ( wrap_cnt++ > 72 ) /* do a line break if needed */ { ps_char( '\n' ); wrap_cnt = 0; } } } /* end while (countdown>0) */ /* sixel_buff has been fully scanned, translated into a sixelfont string, and output; now close the string and clean up */ ps_str( str_show ); /* close paren, 'show' command */ ps_str( str_restore ); /* 'restore' ('save' was just before findsixelfont) */ } /* end of if ( sf_byte_cnt > 0 ) */} /* end of routine output_sixel_as_font *//* * * invalidate_spaced_font_cache * */invalidate_spaced_font_cache ()/* * This routine removes all spaced fonts from the spaced * font cache */{WORD i;for (i = 0; i < SPACING_FONT_TABLE_SIZE; i++) { spacing_font_table [i] .space_active = INACTIVE; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -