Exemple #1
0
void
i_box_filled(i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2, const i_color *val) {
  i_img_dim x, y, width;
  i_palidx index;
  dIMCTXim(im);

  im_log((aIMCTX,1,"i_box_filled(im* %p, p1(" i_DFp "), p2(" i_DFp "),val %p)\n",
	  im, i_DFcp(x1, y1), i_DFcp(x2,y2) ,val));

  if (x1 > x2 || y1 > y2
      || x2 < 0 || y2 < 0
      || x1 >= im->xsize || y1 > im->ysize)
    return;

  if (x1 < 0)
    x1 = 0;
  if (x2 >= im->xsize)
    x2 = im->xsize - 1;
  if (y1 < 0)
    y1 = 0;
  if (y2 >= im->ysize)
    y2 = im->ysize - 1;

  width = x2 - x1 + 1;

  if (im->type == i_palette_type
      && i_findcolor(im, val, &index)) {
    i_palidx *line = mymalloc(sizeof(i_palidx) * width);

    for (x = 0; x < width; ++x)
      line[x] = index;

    for (y = y1; y <= y2; ++y)
      i_ppal(im, x1, x2+1, y, line);

    myfree(line);
  }
  else {
    i_color *line = mymalloc(sizeof(i_color) * width);

    for (x = 0; x < width; ++x)
      line[x] = *val;

    for (y = y1; y <= y2; ++y)
      i_plin(im, x1, x2+1, y, line);

    myfree(line);
  }
}
Exemple #2
0
/*
=item i_findcolor(im, color, &entry)

=category Paletted images

Searches the images palette for the given color.

On success sets *I<entry> to the index of the color, and returns true.

On failure returns false.

Always fails on direct color images.

=cut
*/
int
(i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
  return i_findcolor(im, color, entry);
}