mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Fix love.graphics.newImage(ImageData). Thanks Santos!
--HG-- branch : minor
This commit is contained in:
@@ -674,9 +674,13 @@ getImageData(lua_State *L, int idx, bool allowcompressed, float *density)
|
|||||||
StrongRef<image::ImageData> idata;
|
StrongRef<image::ImageData> idata;
|
||||||
StrongRef<image::CompressedImageData> cdata;
|
StrongRef<image::CompressedImageData> cdata;
|
||||||
|
|
||||||
// Convert to ImageData / CompressedImageData, if necessary.
|
if (luax_istype(L, idx, image::ImageData::type))
|
||||||
if (lua_isstring(L, idx) || luax_istype(L, idx, filesystem::File::type) || luax_istype(L, idx, Data::type))
|
idata.set(image::luax_checkimagedata(L, idx));
|
||||||
|
else if (luax_istype(L, idx, image::CompressedImageData::type))
|
||||||
|
cdata.set(image::luax_checkcompressedimagedata(L, idx));
|
||||||
|
else if (filesystem::luax_cangetdata(L, idx))
|
||||||
{
|
{
|
||||||
|
// Convert to ImageData / CompressedImageData.
|
||||||
auto imagemodule = Module::getInstance<image::Image>(Module::M_IMAGE);
|
auto imagemodule = Module::getInstance<image::Image>(Module::M_IMAGE);
|
||||||
if (imagemodule == nullptr)
|
if (imagemodule == nullptr)
|
||||||
luaL_error(L, "Cannot load images without the love.image module.");
|
luaL_error(L, "Cannot load images without the love.image module.");
|
||||||
@@ -690,10 +694,7 @@ getImageData(lua_State *L, int idx, bool allowcompressed, float *density)
|
|||||||
luax_catchexcept(L, [&]() { cdata.set(imagemodule->newCompressedData(fdata), Acquire::NORETAIN); });
|
luax_catchexcept(L, [&]() { cdata.set(imagemodule->newCompressedData(fdata), Acquire::NORETAIN); });
|
||||||
else
|
else
|
||||||
luax_catchexcept(L, [&]() { idata.set(imagemodule->newImageData(fdata), Acquire::NORETAIN); });
|
luax_catchexcept(L, [&]() { idata.set(imagemodule->newImageData(fdata), Acquire::NORETAIN); });
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (luax_istype(L, idx, image::CompressedImageData::type))
|
|
||||||
cdata.set(image::luax_checkcompressedimagedata(L, idx));
|
|
||||||
else
|
else
|
||||||
idata.set(image::luax_checkimagedata(L, idx));
|
idata.set(image::luax_checkimagedata(L, idx));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user