Beispiel #1
0
static void
fill_8 (/* in */   unsigned char *to_index,
      /* in */     int    x,
      /* in */     int    y,
      /* in */     int    width,
      /* in */     int    height,
      /* in/out */ unsigned char *bitmap,
      /* in/out */ unsigned char *mask)
{
  int x1, x2;

  if (y < 0 || y >= height || mask[y * width + x] != 2)
    return;

  for (x1 = x; x1 >= 0 && mask[y * width + x1] == 2; x1--) ;
  x1++;
  for (x2 = x; x2 < width && mask[y * width + x2] == 2; x2++) ;
  x2--;

  assert (x1 >= 0 && x2 < width);

  for (x = x1; x <= x2; x++)
    {
      bitmap[(y * width + x)    ] = to_index[0];
      mask[y * width + x] = 3;
    }

  for (x = x1; x <= x2; x++)
    {
      fill_8 (to_index, x, y - 1, width, height, bitmap, mask);
      fill_8 (to_index, x, y + 1, width, height, bitmap, mask);
    }
}
Beispiel #2
0
static gboolean
recolor_8 (/* in */   double adaptive_tightness,
         /* in */     int    x,
         /* in */     int    y,
         /* in */     int    width,
         /* in */     int    height,
         /* in/out */ unsigned char *bitmap,
         /* in/out */ unsigned char *mask)
{
  unsigned char *index, *to_index;
  int error_amt;

  index = &bitmap[(y * width + x)    ];
  to_index = NULL;
  error_amt = 0;

  find_most_similar_neighbor_8 (index, &to_index, &error_amt,
                              x, y, width, height, bitmap, mask);

  /* This condition only fails if the bitmap is all the same color */
  if (to_index != NULL)
    {
      /*
       * If the difference between the two colors is too great,
       * don't coalesce the feature with its neighbor(s).  This prevents a
       * color from turning into its complement.
       */

      if (calc_error_8 (index, to_index) > adaptive_tightness)
        fill_8 (index, x, y, width, height, bitmap, mask);
      else
        {
          fill_8 (to_index, x, y, width, height, bitmap, mask);

          return TRUE;
        }
    }

  return FALSE;
}
Beispiel #3
0
Logger::Logger (string name, LogLevel level)
        : m_name(fill_8(name)), m_level(level)
{}