Commit c6f42868 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Use 3 digits instead of 3 to display colored surfaces

parent 1b8e6a0e
...@@ -462,14 +462,14 @@ static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int ...@@ -462,14 +462,14 @@ static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int
size_t console_size; size_t console_size;
if (ansi_terminal){ if (ansi_terminal){
console_size=length0*width*height*8+height; //8 bytes per pixel for colors + return char for each line. console_size=length0*width*height*9+height; //9 bytes per pixel for colors + return char for each line.
if (!ansi_texts) { if (!ansi_texts) {
ansi_texts = MANY_ALLOCATIONS(256*2, char); ansi_texts = MANY_ALLOCATIONS(256*3, char);
uchar_bar_colors = MANY_ALLOCATIONS(256, char); uchar_bar_colors = MANY_ALLOCATIONS(256, char);
FOR(i, 256) FOR(i, 256)
{ {
sprintf(tmp_string, "%.2d ", i%100); sprintf(tmp_string, "%.3d ", i);
memcpy(ansi_texts+i*2, tmp_string, 2); memcpy(ansi_texts+i*3, tmp_string, 3);
uchar_bar_colors[i] = blc_bar_colors[i*BLC_BAR_COLORS_NB/256]; uchar_bar_colors[i] = blc_bar_colors[i*BLC_BAR_COLORS_NB/256];
} }
} }
...@@ -501,8 +501,10 @@ static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int ...@@ -501,8 +501,10 @@ static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int
} }
console_buffer.chars[console_size++]='m'; console_buffer.chars[console_size++]='m';
} }
console_buffer.chars[console_size++]=ansi_texts[value*2]; console_buffer.chars[console_size++]=ansi_texts[value*3];
console_buffer.chars[console_size++]=ansi_texts[value*2+1]; console_buffer.chars[console_size++]=ansi_texts[value*3+1];
console_buffer.chars[console_size++]=ansi_texts[value*3+2];
// console_buffer.data[console_size++]=' '; // console_buffer.data[console_size++]=' ';
previous_color_id=color_id; previous_color_id=color_id;
} }
......
...@@ -80,7 +80,7 @@ int main(int argc, char **argv){ ...@@ -80,7 +80,7 @@ int main(int argc, char **argv){
//Display the array as a array of decimals) //Display the array as a array of decimals)
pixel_array.fprint_surface_uchars(stderr); pixel_array.fprint_surface_uchars(stderr);
fprintf(stderr, "\nWe display the array of intensities as compact colored values (two last digits)\n\n"); fprintf(stderr, "\nWe display the array of intensities as compact colored values\n\n");
//Display the array as a compact surface of color (ansi_terminal). Ideal for images //Display the array as a compact surface of color (ansi_terminal). Ideal for images
pixel_array.fprint_surface_uchars(stderr, 1); pixel_array.fprint_surface_uchars(stderr, 1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment