add impl for grayscale_to_alpha (e.g. devseed world glass effect) - #609
This commit is contained in:
parent
0a300c8be7
commit
5c424d2e7c
1 changed files with 18 additions and 4 deletions
|
@ -93,7 +93,22 @@ image_32::~image_32() {}
|
||||||
|
|
||||||
void image_32::set_grayscale_to_alpha()
|
void image_32::set_grayscale_to_alpha()
|
||||||
{
|
{
|
||||||
|
for (int y = 0; y < height_; ++y)
|
||||||
|
{
|
||||||
|
unsigned int* row_from = data_.getRow(y);
|
||||||
|
for (int x = 0; x < width_; ++x)
|
||||||
|
{
|
||||||
|
unsigned rgba = row_from[x];
|
||||||
|
unsigned r = rgba & 0xff;
|
||||||
|
unsigned g = (rgba >> 8 ) & 0xff;
|
||||||
|
unsigned b = (rgba >> 16) & 0xff;
|
||||||
|
|
||||||
|
// magic numbers for grayscale
|
||||||
|
unsigned a = (int)((r * .3) + (g * .59) + (b * .11));
|
||||||
|
|
||||||
|
row_from[x] = (a << 24)| (255 << 16) | (255 << 8) | (255) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_32::set_color_to_alpha(const color& c)
|
void image_32::set_color_to_alpha(const color& c)
|
||||||
|
@ -113,8 +128,7 @@ void image_32::set_alpha(float opacity)
|
||||||
|
|
||||||
#ifdef MAPNIK_BIG_ENDIAN
|
#ifdef MAPNIK_BIG_ENDIAN
|
||||||
unsigned a0 = (rgba & 0xff);
|
unsigned a0 = (rgba & 0xff);
|
||||||
//unsigned a1 = int( (rgba & 0xff) * opacity );
|
unsigned a1 = int( (rgba & 0xff) * opacity );
|
||||||
unsigned a1 = opacity;
|
|
||||||
|
|
||||||
if (a0 == a1) continue;
|
if (a0 == a1) continue;
|
||||||
|
|
||||||
|
@ -126,8 +140,8 @@ void image_32::set_alpha(float opacity)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
unsigned a0 = (rgba >> 24) & 0xff;
|
unsigned a0 = (rgba >> 24) & 0xff;
|
||||||
//unsigned a1 = int( ((rgba >> 24) & 0xff) * opacity );
|
unsigned a1 = int( ((rgba >> 24) & 0xff) * opacity );
|
||||||
unsigned a1 = opacity;
|
//unsigned a1 = opacity;
|
||||||
if (a0 == a1) continue;
|
if (a0 == a1) continue;
|
||||||
|
|
||||||
unsigned r = rgba & 0xff;
|
unsigned r = rgba & 0xff;
|
||||||
|
|
Loading…
Reference in a new issue