Mask color is used in all routines that draw an image (Indexed, RGB, Grayscale).

This commit is contained in:
David Capello 2010-08-11 21:39:50 -03:00
parent 978f39d721
commit 2f38b83ce3
2 changed files with 18 additions and 5 deletions

View File

@ -144,6 +144,7 @@ public:
virtual void merge(const Image* src, int x, int y, int opacity, int blend_mode)
{
BLEND_COLOR blender = Traits::get_blender(blend_mode);
register int mask_color = src->mask_color;
Image* dst = this;
address_t src_address;
address_t dst_address;
@ -191,7 +192,8 @@ public:
dst_address = ((ImageImpl<Traits>*)dst)->line_address(ydst)+xbeg;
for (xdst=xbeg; xdst<=xend; xdst++) {
*dst_address = (*blender)(*dst_address, *src_address, opacity);
if (*src_address != mask_color)
*dst_address = (*blender)(*dst_address, *src_address, opacity);
dst_address++;
src_address++;

View File

@ -34,17 +34,22 @@ template<class DstTraits, class SrcTraits>
class BlenderHelper
{
BLEND_COLOR m_blend_color;
ase_uint32 m_mask_color;
public:
BlenderHelper(const Image* src, const Palette* pal, int blend_mode)
{
m_blend_color = SrcTraits::get_blender(blend_mode);
m_mask_color = src->mask_color;
}
inline void operator()(typename DstTraits::address_t& scanline_address,
typename DstTraits::address_t& dst_address,
typename SrcTraits::address_t& src_address,
int opacity)
{
*scanline_address = (*m_blend_color)(*dst_address, *src_address, opacity);
if (*src_address != m_mask_color)
*scanline_address = (*m_blend_color)(*dst_address, *src_address, opacity);
else
*scanline_address = *dst_address;
}
};
@ -52,18 +57,24 @@ template<>
class BlenderHelper<RgbTraits, GrayscaleTraits>
{
BLEND_COLOR m_blend_color;
ase_uint32 m_mask_color;
public:
BlenderHelper(const Image* src, const Palette* pal, int blend_mode)
{
m_blend_color = RgbTraits::get_blender(blend_mode);
m_mask_color = src->mask_color;
}
inline void operator()(RgbTraits::address_t& scanline_address,
RgbTraits::address_t& dst_address,
GrayscaleTraits::address_t& src_address,
int opacity)
{
int v = _graya_getv(*src_address);
*scanline_address = (*m_blend_color)(*dst_address, _rgba(v, v, v, _graya_geta(*src_address)), opacity);
if (*src_address != m_mask_color) {
int v = _graya_getv(*src_address);
*scanline_address = (*m_blend_color)(*dst_address, _rgba(v, v, v, _graya_geta(*src_address)), opacity);
}
else
*scanline_address = *dst_address;
}
};
@ -72,7 +83,7 @@ class BlenderHelper<RgbTraits, IndexedTraits>
{
const Palette* m_pal;
int m_blend_mode;
int m_mask_color;
ase_uint32 m_mask_color;
public:
BlenderHelper(const Image* src, const Palette* pal, int blend_mode)
{