Allow modifying alpha when mapping pixel values on ARGB32 surfaces.

Originally committed to SVN as r1799.
This commit is contained in:
Niels Martin Hansen 2008-01-20 23:42:54 +00:00
parent 084eddd7cf
commit 23dc318406
2 changed files with 5 additions and 2 deletions

View File

@ -203,6 +203,7 @@ The following new registers are made available to the expression evaluator:
R In range 0..1, red component. Input and output.
G Ditto, for green component.
B Ditto, for blue component.
A Ditto, for alpha component. (Only on ARGB32 surfaces.)
X X-coordinate of pixel being processed. Input only.
Y Y-coordinate of pixel being processed. Input only.

View File

@ -727,12 +727,14 @@ static int pixel_value_map(lua_State *L)
machine.registers[0] = (double)p.R() / 255.0;
machine.registers[1] = (double)p.G() / 255.0;
machine.registers[2] = (double)p.B() / 255.0;
machine.registers[3] = x;
machine.registers[4] = y;
machine.registers[3] = (double)p.A() / 255.0;
machine.registers[4] = x;
machine.registers[5] = y;
machine.Run();
p.R() = (uint8_t)(machine.registers[0] * 255);
p.G() = (uint8_t)(machine.registers[1] * 255);
p.B() = (uint8_t)(machine.registers[2] * 255);
p.A() = (uint8_t)(machine.registers[3] * 255);
}
}
}