ImageData (and Images loaded from them) now support different data formats. Resolves issue #1048.

Currently exposed formats are rgba8 and rgba16 (normalized), and rgba16f and rgba32f (floating-point). Some systems, especially mobile ones, won't support every format when creating a love.graphics Image. Use love.graphics.getRawImageFormats to check for support.

love.image.newImageData now takes an optional format parameter as its third argument when creating an empty sized ImageData. It defaults to rgba8.

16-bit PNGs, .hdr images, and floating-point OpenEXR images can now be loaded via love.image.newImageData and love.graphics.newImage.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-05-22 15:28:20 -03:00
parent 3e6d01748e
commit e71f95595c
31 changed files with 12018 additions and 241 deletions
+21 -1
View File
@@ -1416,13 +1416,32 @@ int w_getCanvasFormats(lua_State *L)
return 1;
}
int w_getRawImageFormats(lua_State *L)
{
lua_createtable(L, 0, (int) image::ImageData::FORMAT_MAX_ENUM);
for (int i = 0; i < (int) image::ImageData::FORMAT_MAX_ENUM; i++)
{
auto format = (image::ImageData::Format) i;
const char *name = nullptr;
if (!image::ImageData::getConstant(format, name))
continue;
luax_pushboolean(L, Image::hasTextureSupport(format));
lua_setfield(L, -2, name);
}
return 1;
}
int w_getCompressedImageFormats(lua_State *L)
{
lua_createtable(L, 0, (int) image::CompressedImageData::FORMAT_MAX_ENUM);
for (int i = 0; i < (int) image::CompressedImageData::FORMAT_MAX_ENUM; i++)
{
image::CompressedImageData::Format format = (image::CompressedImageData::Format) i;
auto format = (image::CompressedImageData::Format) i;
const char *name = nullptr;
if (format == image::CompressedImageData::FORMAT_UNKNOWN)
@@ -1996,6 +2015,7 @@ static const luaL_Reg functions[] =
{ "getSupported", w_getSupported },
{ "getCanvasFormats", w_getCanvasFormats },
{ "getRawImageFormats", w_getRawImageFormats },
{ "getCompressedImageFormats", w_getCompressedImageFormats },
{ "getRendererInfo", w_getRendererInfo },
{ "getSystemLimits", w_getSystemLimits },