예제 #1
0
static bool is_same_pixel(PixelFormat pixelFormat, color_t pixel1, color_t pixel2)
{
  switch (pixelFormat) {
    case IMAGE_RGB:
      if (rgba_geta(pixel1) == 0 && rgba_geta(pixel2) == 0)
        return true;
      break;
    case IMAGE_GRAYSCALE:
      if (graya_geta(pixel1) == 0 && graya_geta(pixel2) == 0)
        return true;
      break;
  }
  return pixel1 == pixel2;
}
예제 #2
0
static inline bool color_equal_16(color_t c1, color_t c2, int tolerance)
{
  if (tolerance == 0)
    return (c1 == c2) || (graya_geta(c1) == 0 && graya_geta(c2) == 0);
  else {
    int k1 = graya_getv(c1);
    int a1 = graya_geta(c1);
    int k2 = graya_getv(c2);
    int a2 = graya_geta(c2);

    if (a1 == 0 && a2 == 0)
      return true;

    return ((ABS(k1-k2) <= tolerance) &&
            (ABS(a1-a2) <= tolerance));
  }
}
예제 #3
0
파일: render.cpp 프로젝트: vmrob/aseprite
 inline void operator()(RgbTraits::pixel_t& scanline,
                        const RgbTraits::pixel_t& dst,
                        const GrayscaleTraits::pixel_t& src,
                        int opacity)
 {
   if (src != m_mask_color) {
     int v = graya_getv(src);
     scanline = (*m_blend_color)(dst, rgba(v, v, v, graya_geta(src)), opacity);
   }
   else
     scanline = dst;
 }
예제 #4
0
파일: sprite.cpp 프로젝트: airways/aseprite
void Sprite::pickCels(int x, int y, frame_t frame, int opacityThreshold, CelList& cels) const
{
  std::vector<Layer*> layers;
  getLayersList(layers);

  for (int i=(int)layers.size()-1; i>=0; --i) {
    Layer* layer = layers[i];
    if (!layer->isImage() || !layer->isVisible())
      continue;

    Cel* cel = layer->cel(frame);
    if (!cel)
      continue;

    Image* image = cel->image();
    if (!image)
      continue;

    if (!cel->bounds().contains(gfx::Point(x, y)))
      continue;

    color_t color = get_pixel(image,
      x - cel->x(),
      y - cel->y());

    bool isOpaque = true;

    switch (image->pixelFormat()) {
      case IMAGE_RGB:
        isOpaque = (rgba_geta(color) >= opacityThreshold);
        break;
      case IMAGE_INDEXED:
        isOpaque = (color != image->maskColor());
        break;
      case IMAGE_GRAYSCALE:
        isOpaque = (graya_geta(color) >= opacityThreshold);
        break;
    }

    if (!isOpaque)
      continue;

    cels.push_back(cel);
  }
  fflush(stdout);
}
예제 #5
0
raster::color_t color_utils::fixup_color_for_background(PixelFormat format, raster::color_t color)
{
  switch (format) {
    case IMAGE_RGB:
      if (rgba_geta(color) < 255) {
        return rgba(rgba_getr(color),
                    rgba_getg(color),
                    rgba_getb(color), 255);
      }
      break;
    case IMAGE_GRAYSCALE:
      if (graya_geta(color) < 255) {
        return graya(graya_getv(color), 255);
      }
      break;
  }
  return color;
}
예제 #6
0
int convert_color_to_allegro<GrayscaleTraits, 32>(color_t c, const Palette* palette) {
  return makeacol32(graya_getv(c), graya_getv(c), graya_getv(c), graya_geta(c));
}