Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions
in_cmap.c File Reference
#include "getx11.h"
Include dependency graph for in_cmap.c:

Go to the source code of this file.

Functions

void check_mono_color (image_information *img, rle_hdr *img_hdr)
 
void get_dither_colors (image_information *img, rle_hdr *img_hdr)
 
int eq_cmap (rle_pixel **cm1, int len1, rle_pixel **cm2, int len2)
 

Function Documentation

void check_mono_color ( image_information img,
rle_hdr img_hdr 
)

Definition at line 32 of file in_cmap.c.

35 {
36  /* Get some info out of the RLE header. */
37  img->ncmap = img_hdr->ncmap;
38  {
39  char * v;
40  if ( (v = rle_getcom( "color_map_length", img_hdr )) != NULL )
41  img->cmlen = atoi( v );
42  else
43  img->cmlen = 1 << img_hdr->cmaplen;
44 
45  /* Protect against bogus information */
46  if ( img->cmlen < 0 )
47  img->cmlen = 0;
48  if ( img->cmlen > 256 )
49  img->cmlen = 256;
50  }
51 
52  /* The mono_color flag means that a single input channel is being
53  * pseudocolored by a multi-channel colormap.
54  */
55  img->mono_color = (img->img_channels == 1 && img->ncmap == 3 &&
56  img->cmlen);
57 
58 }
char * rle_getcom(const char *name, rle_hdr *the_hdr)
Boolean mono_color
Definition: getx11.h:168
int ncmap
Definition: rle.h:100
int cmaplen
Definition: rle.h:100
int eq_cmap ( rle_pixel **  cm1,
int  len1,
rle_pixel **  cm2,
int  len2 
)

Definition at line 120 of file in_cmap.c.

123 {
124  register int i, j;
125 
126  if (cm1 && cm2) {
127  if ( len1 != len2 )
128  return 0;
129  for (i = 0; i < 3; i++ )
130  for (j = 0; j < len1; j++)
131  if ( cm1[i][j] != cm2[i][j] )
132  return 0;
133  } else
134  if (cm1 || cm2)
135  return 0;
136  return 1;
137 }
int i
Definition: rletorla.c:82
void get_dither_colors ( image_information img,
rle_hdr img_hdr 
)

Definition at line 63 of file in_cmap.c.

66 {
67  register int i, j;
68 
69  /* Input map, at least 3 channels */
70  if ( img->sep_colors ||
71  (img->img_channels == 1 && img->ncmap == 3 && img->cmlen) )
72  /* If using color map directly, apply display gamma, too. */
73  img->in_cmap = buildmap( img_hdr, 3, img->gamma,
74  display_gamma );
75  else
76  img->in_cmap = buildmap( img_hdr, 3, img->gamma, 1.0 );
77 
78  for (i = 0; i < 3; i++ ) {
79  for (j = 0; j < 256; j++)
80  if ( img->in_cmap[i][j] != j )
81  break;
82  if (j < 256) break;
83  }
84  /* if i and j are maxed out, then in_cmap is the identity... */
85  if ( i == 3 && j == 256 && !img->mono_color )
86  img->in_cmap = NULL;
87  else
88  if ( debug_flag && !( i == 3 && j == 256) ) {
89  for (i = 0; i < 3; i++ ) {
90  fprintf(stderr, "Input image colormap channel %d:\n", i);
91  if ( i > 0 )
92  for ( j = 0; j < img->cmlen; j++ )
93  if (img->in_cmap[i-1][j] != img->in_cmap[i][j])
94  break;
95  if ( i > 0 && j == img->cmlen )
96  fprintf( stderr, "\tSame as channel %d\n", i - 1 );
97  else
98  for (j = 0; j < img->cmlen; j += 16) {
99  int k;
100  fprintf (stderr, "%3d: ", j );
101  for (k = 0; k < 16 ; k++ )
102  if ( j + k < img->cmlen )
103  fprintf(stderr, "%3d ", img->in_cmap[i][j+k]);
104  fprintf (stderr, "\n");
105  }
106  }
107  }
108 
109  /* make colormap monochrome... Whatahack! */
110  if ( img->mono_color && !img->color_dpy ) {
111  for (j = 0; j < 256; j++)
112  img->in_cmap[0][j] = (rle_pixel)
113  ((30 * img->in_cmap[0][j] + 59 * img->in_cmap[1][j] +
114  11 * img->in_cmap[2][j]) / 100);
115 
116  img->mono_color = False;
117  }
118 }
double display_gamma
Definition: getx11.c:64
Boolean mono_color
Definition: getx11.h:168
Boolean color_dpy
Definition: getx11.h:169
boolean debug_flag
Definition: get_orion.c:79
Boolean sep_colors
Definition: getx11.h:167
rle_pixel ** buildmap(rle_hdr *the_hdr, int minmap, double orig_gamma, double new_gamma)
Definition: buildmap.c:56
unsigned char rle_pixel
Definition: rle.h:56
int i
Definition: rletorla.c:82
rle_pixel ** in_cmap
Definition: getx11.h:171