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)); } }
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; }
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; }
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)); }
int convert_color_to_allegro<GrayscaleTraits, 24>(color_t c, const Palette* palette) { return makecol24(graya_getv(c), graya_getv(c), graya_getv(c)); }