Clamp all color arguments to [0, 1] in cases where values outside that range don't make sense (fixed-point color values & sRGB colors). Closes issue #1315.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-11-21 19:49:52 -04:00
parent 1cd1a8d32e
commit 6dea2ab714
9 changed files with 59 additions and 36 deletions
+4 -6
View File
@@ -88,22 +88,20 @@ int w_ImageData_getDimensions(lua_State *L)
return 2;
}
// TODO: rgba16f
static void luax_checkpixel_rgba8(lua_State *L, int startidx, Pixel &p)
{
for (int i = 0; i < 3; i++)
p.rgba8[i] = (uint8) (luaL_checknumber(L, startidx + i) * 255.0);
p.rgba8[i] = (uint8) (luax_checknumberclamped01(L, startidx + i) * 255.0);
p.rgba8[3] = (uint8) (luaL_optnumber(L, startidx + 3, 1.0) * 255.0);
p.rgba8[3] = (uint8) (luax_optnumberclamped01(L, startidx + 3, 1.0) * 255.0);
}
static void luax_checkpixel_rgba16(lua_State *L, int startidx, Pixel &p)
{
for (int i = 0; i < 3; i++)
p.rgba16[i] = (uint16) (luaL_checknumber(L, startidx + i) * 65535.0);
p.rgba16[i] = (uint16) (luax_checknumberclamped01(L, startidx + i) * 65535.0);
p.rgba16[3] = (uint16) (luaL_optnumber(L, startidx + 3, 1.0) * 65535.0);
p.rgba16[3] = (uint16) (luax_optnumberclamped01(L, startidx + 3, 1.0) * 65535.0);
}
static void luax_checkpixel_rgba16f(lua_State *L, int startidx, Pixel &p)