mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
love.filesystem.newFileData now accepts filepaths and File objects. --HG-- branch : image-CompressedData
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "common/Data.h"
|
||||
#include "common/StringMap.h"
|
||||
|
||||
#include "devil/Image.h"
|
||||
#include "magpie/Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -55,82 +55,47 @@ int w_newImageData(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Case 2: Data
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data *d = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
ImageData *t = 0;
|
||||
try
|
||||
{
|
||||
t = instance->newImageData(d);
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *)t);
|
||||
return 1;
|
||||
}
|
||||
// Case 2: File(Data).
|
||||
|
||||
// Case 3: String/File.
|
||||
// Convert to FileData, if necessary.
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "filesystem", "newFileData");
|
||||
|
||||
// Convert to File, if necessary.
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
|
||||
|
||||
ImageData *t = 0;
|
||||
try
|
||||
{
|
||||
t = instance->newImageData(file);
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *)t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newCompressedData(lua_State *L)
|
||||
{
|
||||
// Case 1: Data
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data *d = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
|
||||
CompressedData *t = 0;
|
||||
try
|
||||
{
|
||||
t = instance->newCompressedData(d);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
luax_newtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, (void *) t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Case 2: String/File.
|
||||
|
||||
// Convert to File, if necessary.
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
|
||||
CompressedData *t = 0;
|
||||
try
|
||||
{
|
||||
t = instance->newCompressedData(file);
|
||||
t = instance->newImageData(data);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *) t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newCompressedData(lua_State *L)
|
||||
{
|
||||
// Convert to FileData, if necessary.
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "filesystem", "newFileData");
|
||||
|
||||
love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
|
||||
|
||||
CompressedData *t = 0;
|
||||
try
|
||||
{
|
||||
t = instance->newCompressedData(data);
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
luax_newtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, (void *) t);
|
||||
|
||||
return 1;
|
||||
@@ -138,37 +103,22 @@ int w_newCompressedData(lua_State *L)
|
||||
|
||||
int w_isCompressed(lua_State *L)
|
||||
{
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data *d = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
try
|
||||
{
|
||||
bool compressed = instance->isCompressed(d);
|
||||
luax_pushboolean(L, compressed);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
// Convert to FileData, if necessary.
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "filesystem", "newFileData");
|
||||
|
||||
// Convert to File, if necessary.
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
filesystem::File *file = luax_checktype<filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
|
||||
|
||||
bool compressed = false;
|
||||
try
|
||||
{
|
||||
bool compressed = instance->isCompressed(file);
|
||||
luax_pushboolean(L, compressed);
|
||||
compressed = instance->isCompressed(data);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
luax_pushboolean(L, compressed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -194,7 +144,7 @@ extern "C" int luaopen_love_image(lua_State *L)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new love::image::devil::Image();
|
||||
instance = new love::image::magpie::Image();
|
||||
}
|
||||
catch(Exception &e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user