📄 xsps.c
字号:
*index = 0;
free(temp_pattern);
} /* ends shorten_pattern */
/***********************************************
*
* initialize_pattern(...
*
* This function creates an initial pattern
* that is as wide as the pattern_width
* parameter.
*
***********************************************/
void initialize_pattern(pattern, current_width,
max_width, pattern_width,
index)
int pattern[];
int *current_width,
*max_width,
*index,
pattern_width;
{
int i;
for(i=0; i<pattern_width; i++)
pattern[i] = i+PATTERN_START;
*index = 0;
*current_width = pattern_width;
*max_width = pattern_width;
} /* ends initialize_pattern */
/***********************************************
*
* no_change(...
*
* This function processes the pattern
* and does not make any changes to it.
*
***********************************************/
void no_change(pattern, processed_pattern, pp_index,
current_width, index)
int *pattern, *processed_pattern;
int pp_index, current_width, *index;
{
processed_pattern[pp_index] =
pattern[*index];
*index = *index + 1;
if(*index >= current_width)
*index = 0;
} /* ends no_change */
/***********************************************
*
* zero_line(...
*
* This function fills an int array with
* zeros.
*
***********************************************/
void zero_line(array, length)
int *array;
int length;
{
int i;
for(i=0; i<length; i++)
array[i] = 0;
} /* ends zero_line */
/***********************************************
*
* test_print_line(...
*
* This is a debug function that prints
* an array of integers.
*
***********************************************/
void test_print_line(line, width)
int *line;
int width;
{
int i;
for(i=0; i<width; i++)
printf("-%3d", line[i]);
printf("\n");
} /* ends test_print_line */
/***********************************************
*
* read_image_line(...
*
* This function reads a line of pixels from
* a TIFF image file.
*
***********************************************/
void read_image_line(the_image, file_name,
line_number, array, width)
char file_name[];
short the_image[ROWS][COLS];
int *array, line_number, width;
{
int i, il, ie, ll, le,
pixels_to_read,
reading_counter,
still_reading;
il = line_number;
ll = il + 1;
ie = 1;
le = ie + COLS;
if(width < COLS)
le = ie + (width - 1);
pixels_to_read = width;
reading_counter = 0;
still_reading = 1;
while(still_reading){
read_tiff_image(file_name, the_image,
il, ie, ll, le);
for(i=0; i<(le-ie); i++)
array[i + (reading_counter*COLS)] =
the_image[0][i];
reading_counter++;
pixels_to_read = pixels_to_read - (le-ie);
if(pixels_to_read <= 1)
still_reading = 0;
else{
ie = ie + COLS;
le = ie + COLS;
if(le > width)
le = width;
} /* ends else */
} /* ends while still_reading */
} /* ends read_image_line */
/***********************************************
*
* write_image_line(...
*
* This function writes a line of pixels to
* a TIFF image file.
*
***********************************************/
void write_image_line(the_image, file_name,
line_number, array, width)
char file_name[];
short the_image[ROWS][COLS];
int *array, line_number, width;
{
int i, il, ie, ll, le,
pixels_to_write,
writing_counter,
still_writing;
il = line_number;
ll = il + 1;
ie = 1;
le = ie + COLS;
if(width < COLS)
le = ie + (width - 1);
pixels_to_write = width;
writing_counter = 0;
still_writing = 1;
while(still_writing){
for(i=0; i<(le-ie); i++)
the_image[0][i] =
array[i + (writing_counter*COLS)];
writing_counter++;
write_array_into_tiff_image(file_name,
the_image,
il, ie, ll, le);
pixels_to_write = pixels_to_write - (le-ie);
if(pixels_to_write <= 1)
still_writing = 0;
else{
ie = ie + COLS;
le = ie + COLS;
if(le > width)
le = width;
} /* ends else */
} /* ends while still_writing */
} /* ends write_image_line */
/***********************************************
*
* equate_headers(...
*
* This function sets the b image header
* struct equal to all elements of the a
* image header.
*
***********************************************/
void equate_headers(a, b)
struct tiff_header_struct *a, *b;
{
b->lsb = a->lsb;
b->bits_per_pixel = a->bits_per_pixel;
b->image_length = a->image_length;
b->image_width = a->image_width;
b->strip_offset = a->strip_offset;
} /* ends equate_headers */
/***********************************************
*
* s_lengthen_pattern(...
*
* This funtion lengthens the pattern by
* inserting an element(s) into it.
* This is the special lengthen pattern routine.
* It inserts only from the original pattern
* (the special-pixels).
*
***********************************************/
void s_lengthen_pattern(size, pattern, index,
current_width, width,
max_width, s_length)
int size, *index, *current_width,
*pattern, *width, *max_width, s_length;
{
int *temp_pattern;
int count, element, i, new_index, new_width;
temp_pattern =
malloc(KONSTANT*(*width)*sizeof(int));
for(i=0; i<(*width); i++)
temp_pattern[i] = pattern[i];
element = pattern[*index] - PATTERN_START;
new_index = (element - size) % s_length;
/******************************************
*
* Put a new pattern in the pattern array
* starting back at the new_index.
*
******************************************/
for(i=0; i<size; i++){
pattern[i] = new_index + PATTERN_START;
new_index++;
if(new_index == s_length)
new_index = 0;
} /* ends loop over i */
new_width = size + *current_width;
for(i=size; i<new_width; i++){
pattern[i] = temp_pattern[*index];
*index = *index + 1;
if(*index >= *current_width)
*index = 0;
} /* ends loop over i, count */
*current_width = new_width;
*index = 0;
} /* ends s_lengthen_pattern */
/***********************************************
*
* special_substitution(...
*
* This function takes the processed_pattern
* array and substitutes the special pixels
* into it.
*
***********************************************/
void special_substitution(processed_pattern,
special_pixels, width)
int *processed_pattern, *special_pixels, width;
{
int i, place;
for(i=0; i<(KONSTANT*width); i++){
place = processed_pattern[i] - PATTERN_START;
processed_pattern[i] =
special_pixels[place];
} /* ends loop over i */
} /* ends special_substitution */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -