mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Images/[Compressed]ImageData can be created using any Data, instead of just files or FileData.
--HG-- branch : minor
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
// LOVE
|
||||
#include "common/Object.h"
|
||||
#include "filesystem/FileData.h"
|
||||
#include "common/Data.h"
|
||||
#include "CompressedSlice.h"
|
||||
|
||||
namespace love
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
* CompressedImageData by this handler.
|
||||
* @param data The data to parse.
|
||||
**/
|
||||
virtual bool canParse(const filesystem::FileData *data) = 0;
|
||||
virtual bool canParse(const Data *data) = 0;
|
||||
|
||||
/**
|
||||
* Parses compressed image filedata into a list of sub-images and returns
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
*
|
||||
* @return The single block of memory containing the parsed images.
|
||||
**/
|
||||
virtual StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
virtual StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) = 0;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace image
|
||||
|
||||
love::Type CompressedImageData::type("CompressedImageData", &Data::type);
|
||||
|
||||
CompressedImageData::CompressedImageData(const std::list<CompressedFormatHandler *> &formats, love::filesystem::FileData *filedata)
|
||||
CompressedImageData::CompressedImageData(const std::list<CompressedFormatHandler *> &formats, Data *filedata)
|
||||
: format(PIXELFORMAT_UNKNOWN)
|
||||
, sRGB(false)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "common/StringMap.h"
|
||||
#include "common/int.h"
|
||||
#include "common/pixelformat.h"
|
||||
#include "filesystem/FileData.h"
|
||||
#include "CompressedSlice.h"
|
||||
#include "CompressedFormatHandler.h"
|
||||
|
||||
@@ -49,7 +48,7 @@ public:
|
||||
|
||||
static love::Type type;
|
||||
|
||||
CompressedImageData(const std::list<CompressedFormatHandler *> &formats, love::filesystem::FileData *filedata);
|
||||
CompressedImageData(const std::list<CompressedFormatHandler *> &formats, Data *filedata);
|
||||
CompressedImageData(const CompressedImageData &c);
|
||||
virtual ~CompressedImageData();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ FormatHandler::~FormatHandler()
|
||||
{
|
||||
}
|
||||
|
||||
bool FormatHandler::canDecode(love::filesystem::FileData* /*data*/)
|
||||
bool FormatHandler::canDecode(Data* /*data*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ bool FormatHandler::canEncode(PixelFormat /*rawFormat*/, EncodedFormat /*encoded
|
||||
return false;
|
||||
}
|
||||
|
||||
FormatHandler::DecodedImage FormatHandler::decode(love::filesystem::FileData* /*data*/)
|
||||
FormatHandler::DecodedImage FormatHandler::decode(Data* /*data*/)
|
||||
{
|
||||
throw love::Exception("Image decoding is not implemented for this format backend.");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// LOVE
|
||||
#include "common/Object.h"
|
||||
#include "common/pixelformat.h"
|
||||
#include "filesystem/FileData.h"
|
||||
#include "common/Data.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* Whether this format handler can decode a particular FileData.
|
||||
**/
|
||||
virtual bool canDecode(love::filesystem::FileData *data);
|
||||
virtual bool canDecode(Data *data);
|
||||
|
||||
/**
|
||||
* Whether this format handler can encode to a particular format.
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
* @param data The encoded data to decode.
|
||||
* @return The decoded pixel data.
|
||||
**/
|
||||
virtual DecodedImage decode(love::filesystem::FileData *data);
|
||||
virtual DecodedImage decode(Data *data);
|
||||
|
||||
/**
|
||||
* Encodes an image from raw pixel data into a particular format.
|
||||
|
||||
@@ -76,7 +76,7 @@ const char *Image::getName() const
|
||||
return "love.image.magpie";
|
||||
}
|
||||
|
||||
love::image::ImageData *Image::newImageData(love::filesystem::FileData *data)
|
||||
love::image::ImageData *Image::newImageData(Data *data)
|
||||
{
|
||||
return new ImageData(data);
|
||||
}
|
||||
@@ -91,12 +91,12 @@ love::image::ImageData *Image::newImageData(int width, int height, PixelFormat f
|
||||
return new ImageData(width, height, format, data, own);
|
||||
}
|
||||
|
||||
love::image::CompressedImageData *Image::newCompressedData(love::filesystem::FileData *data)
|
||||
love::image::CompressedImageData *Image::newCompressedData(Data *data)
|
||||
{
|
||||
return new CompressedImageData(compressedFormatHandlers, data);
|
||||
}
|
||||
|
||||
bool Image::isCompressed(love::filesystem::FileData *data)
|
||||
bool Image::isCompressed(Data *data)
|
||||
{
|
||||
for (CompressedFormatHandler *handler : compressedFormatHandlers)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* @param data The FileData containing the encoded image data.
|
||||
* @return The new ImageData.
|
||||
**/
|
||||
ImageData *newImageData(love::filesystem::FileData *data);
|
||||
ImageData *newImageData(Data *data);
|
||||
|
||||
/**
|
||||
* Creates empty ImageData with the given size.
|
||||
@@ -87,13 +87,13 @@ public:
|
||||
* @param data The FileData containing the compressed image data.
|
||||
* @return The new CompressedImageData.
|
||||
**/
|
||||
CompressedImageData *newCompressedData(love::filesystem::FileData *data);
|
||||
CompressedImageData *newCompressedData(Data *data);
|
||||
|
||||
/**
|
||||
* Determines whether a FileData is Compressed image data or not.
|
||||
* @param data The FileData to test.
|
||||
**/
|
||||
bool isCompressed(love::filesystem::FileData *data);
|
||||
bool isCompressed(Data *data);
|
||||
|
||||
std::vector<StrongRef<ImageData>> newCubeFaces(ImageData *src);
|
||||
std::vector<StrongRef<ImageData>> newVolumeLayers(ImageData *src);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace image
|
||||
|
||||
love::Type ImageData::type("ImageData", &Data::type);
|
||||
|
||||
ImageData::ImageData(love::filesystem::FileData *data)
|
||||
ImageData::ImageData(Data *data)
|
||||
{
|
||||
decode(data);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void ImageData::create(int width, int height, PixelFormat format, void *data)
|
||||
this->format = format;
|
||||
}
|
||||
|
||||
void ImageData::decode(love::filesystem::FileData *data)
|
||||
void ImageData::decode(Data *data)
|
||||
{
|
||||
FormatHandler *decoder = nullptr;
|
||||
FormatHandler::DecodedImage decodedimage;
|
||||
@@ -132,8 +132,15 @@ void ImageData::decode(love::filesystem::FileData *data)
|
||||
|
||||
if (decodedimage.data == nullptr)
|
||||
{
|
||||
const std::string &name = data->getFilename();
|
||||
throw love::Exception("Could not decode file '%s' to ImageData: unsupported file format", name.c_str());
|
||||
auto filedata = dynamic_cast<filesystem::FileData *>(data);
|
||||
|
||||
if (filedata != nullptr)
|
||||
{
|
||||
const std::string &name = filedata->getFilename();
|
||||
throw love::Exception("Could not decode file '%s' to ImageData: unsupported file format", name.c_str());
|
||||
}
|
||||
else
|
||||
throw love::Exception("Could not decode data to ImageData: unsupported encoded format");
|
||||
}
|
||||
|
||||
if (decodedimage.size != decodedimage.width * decodedimage.height * getPixelFormatSize(decodedimage.format))
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
static love::Type type;
|
||||
|
||||
ImageData(love::filesystem::FileData *data);
|
||||
ImageData(Data *data);
|
||||
ImageData(int width, int height, PixelFormat format = PIXELFORMAT_RGBA8);
|
||||
ImageData(int width, int height, PixelFormat format, void *data, bool own);
|
||||
ImageData(const ImageData &c);
|
||||
@@ -132,7 +132,7 @@ private:
|
||||
void create(int width, int height, PixelFormat format, void *data = nullptr);
|
||||
|
||||
// Decode and load an encoded format.
|
||||
void decode(love::filesystem::FileData *data);
|
||||
void decode(Data *data);
|
||||
|
||||
// The actual data.
|
||||
unsigned char *data = nullptr;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// LOVE
|
||||
#include "ASTCHandler.h"
|
||||
#include "common/int.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -86,7 +87,7 @@ static PixelFormat convertFormat(uint32 blockX, uint32 blockY, uint32 blockZ)
|
||||
|
||||
} // Anonymous namespace.
|
||||
|
||||
bool ASTCHandler::canParse(const filesystem::FileData *data)
|
||||
bool ASTCHandler::canParse(const Data *data)
|
||||
{
|
||||
if (data->getSize() <= sizeof(ASTCHeader))
|
||||
return false;
|
||||
@@ -104,7 +105,7 @@ bool ASTCHandler::canParse(const filesystem::FileData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
StrongRef<CompressedMemory> ASTCHandler::parse(filesystem::FileData *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<CompressedMemory> ASTCHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not an .astc file?)");
|
||||
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
virtual ~ASTCHandler() {}
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
bool canParse(const filesystem::FileData *data) override;
|
||||
bool canParse(const Data *data) override;
|
||||
|
||||
StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) override;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// LOVE
|
||||
#include "EXRHandler.h"
|
||||
#include "common/halffloat.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
// tinyexr
|
||||
#define TINYEXR_IMPLEMENTATION
|
||||
@@ -36,7 +37,7 @@ namespace image
|
||||
namespace magpie
|
||||
{
|
||||
|
||||
bool EXRHandler::canDecode(love::filesystem::FileData *data)
|
||||
bool EXRHandler::canDecode(Data *data)
|
||||
{
|
||||
EXRVersion version;
|
||||
return ParseEXRVersionFromMemory(&version, (const unsigned char *) data->getData(), data->getSize()) == TINYEXR_SUCCESS;
|
||||
@@ -100,7 +101,7 @@ static T *loadEXRChannels(int width, int height, T *rgba[4], T one)
|
||||
return data;
|
||||
}
|
||||
|
||||
FormatHandler::DecodedImage EXRHandler::decode(love::filesystem::FileData *data)
|
||||
FormatHandler::DecodedImage EXRHandler::decode(Data *data)
|
||||
{
|
||||
const char *err = "unknown error";
|
||||
auto mem = (const unsigned char *) data->getData();
|
||||
|
||||
@@ -38,10 +38,10 @@ public:
|
||||
|
||||
// Implements FormatHandler.
|
||||
|
||||
virtual bool canDecode(love::filesystem::FileData *data);
|
||||
virtual bool canDecode(Data *data);
|
||||
virtual bool canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat);
|
||||
|
||||
virtual DecodedImage decode(love::filesystem::FileData *data);
|
||||
virtual DecodedImage decode(Data *data);
|
||||
virtual EncodedImage encode(const DecodedImage &img, EncodedFormat format);
|
||||
|
||||
virtual void free(unsigned char *mem);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// LOVE
|
||||
#include "KTXHandler.h"
|
||||
#include "common/int.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
// C
|
||||
#include <string.h>
|
||||
@@ -280,7 +281,7 @@ PixelFormat convertFormat(uint32 glformat, bool &sRGB)
|
||||
|
||||
} // Anonymous namespace.
|
||||
|
||||
bool KTXHandler::canParse(const filesystem::FileData *data)
|
||||
bool KTXHandler::canParse(const Data *data)
|
||||
{
|
||||
if (data->getSize() < sizeof(KTXHeader))
|
||||
return false;
|
||||
@@ -297,7 +298,7 @@ bool KTXHandler::canParse(const filesystem::FileData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
StrongRef<CompressedMemory> KTXHandler::parse(filesystem::FileData *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<CompressedMemory> KTXHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a KTX file?)");
|
||||
|
||||
@@ -40,9 +40,9 @@ public:
|
||||
virtual ~KTXHandler() {}
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
bool canParse(const filesystem::FileData *data) override;
|
||||
bool canParse(const Data *data) override;
|
||||
|
||||
StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) override;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// LOVE
|
||||
#include "PKMHandler.h"
|
||||
#include "common/int.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -96,7 +97,7 @@ static PixelFormat convertFormat(uint16 texformat)
|
||||
|
||||
} // Anonymous namespace.
|
||||
|
||||
bool PKMHandler::canParse(const filesystem::FileData *data)
|
||||
bool PKMHandler::canParse(const Data *data)
|
||||
{
|
||||
if (data->getSize() <= sizeof(PKMHeader))
|
||||
return false;
|
||||
@@ -113,7 +114,7 @@ bool PKMHandler::canParse(const filesystem::FileData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
StrongRef<CompressedMemory> PKMHandler::parse(filesystem::FileData *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<CompressedMemory> PKMHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a PKM file?)");
|
||||
|
||||
@@ -40,9 +40,9 @@ public:
|
||||
virtual ~PKMHandler() {}
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
bool canParse(const filesystem::FileData *data) override;
|
||||
bool canParse(const Data *data) override;
|
||||
|
||||
StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) override;
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ static unsigned zlibCompress(unsigned char **out, size_t *outsize, const unsigne
|
||||
return 0; // Success.
|
||||
}
|
||||
|
||||
bool PNGHandler::canDecode(love::filesystem::FileData *data)
|
||||
bool PNGHandler::canDecode(Data *data)
|
||||
{
|
||||
unsigned int width = 0, height = 0;
|
||||
unsigned char *indata = (unsigned char *) data->getData();
|
||||
@@ -146,7 +146,7 @@ bool PNGHandler::canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat)
|
||||
&& (rawFormat == PIXELFORMAT_RGBA8 || rawFormat == PIXELFORMAT_RGBA16);
|
||||
}
|
||||
|
||||
PNGHandler::DecodedImage PNGHandler::decode(love::filesystem::FileData *fdata)
|
||||
PNGHandler::DecodedImage PNGHandler::decode(Data *fdata)
|
||||
{
|
||||
unsigned int width = 0, height = 0;
|
||||
unsigned char *indata = (unsigned char *) fdata->getData();
|
||||
|
||||
@@ -39,10 +39,10 @@ public:
|
||||
|
||||
// Implements FormatHandler.
|
||||
|
||||
virtual bool canDecode(love::filesystem::FileData *data);
|
||||
virtual bool canDecode(Data *data);
|
||||
virtual bool canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat);
|
||||
|
||||
virtual DecodedImage decode(love::filesystem::FileData *data);
|
||||
virtual DecodedImage decode(Data *data);
|
||||
virtual EncodedImage encode(const DecodedImage &img, EncodedFormat format);
|
||||
|
||||
virtual void free(unsigned char *mem);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// LOVE
|
||||
#include "PVRHandler.h"
|
||||
#include "common/int.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
// C++
|
||||
#include <algorithm>
|
||||
@@ -453,7 +454,7 @@ size_t getMipLevelSize(const PVRTexHeaderV3 &header, int miplevel)
|
||||
} // Anonymous namespace.
|
||||
|
||||
|
||||
bool PVRHandler::canParse(const filesystem::FileData *data)
|
||||
bool PVRHandler::canParse(const Data *data)
|
||||
{
|
||||
if (data->getSize() < sizeof(PVRTexHeaderV2) || data->getSize() < sizeof(PVRTexHeaderV3))
|
||||
return false;
|
||||
@@ -474,7 +475,7 @@ bool PVRHandler::canParse(const filesystem::FileData *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
StrongRef<CompressedMemory> PVRHandler::parse(filesystem::FileData *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<CompressedMemory> PVRHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a PVR file?)");
|
||||
|
||||
@@ -38,9 +38,9 @@ public:
|
||||
virtual ~PVRHandler() {}
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
bool canParse(const filesystem::FileData *data) override;
|
||||
bool canParse(const Data *data) override;
|
||||
|
||||
StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) override;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
// LOVE
|
||||
#include "STBHandler.h"
|
||||
#include "image/ImageData.h"
|
||||
#include "common/Exception.h"
|
||||
#include "common/Color.h"
|
||||
|
||||
static void loveSTBIAssert(bool test, const char *teststr)
|
||||
@@ -52,7 +52,7 @@ namespace magpie
|
||||
|
||||
static_assert(sizeof(Color) == 4, "sizeof(Color) must equal 4 bytes!");
|
||||
|
||||
bool STBHandler::canDecode(love::filesystem::FileData *data)
|
||||
bool STBHandler::canDecode(Data *data)
|
||||
{
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
@@ -69,7 +69,7 @@ bool STBHandler::canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat)
|
||||
return encodedFormat == ENCODED_TGA && rawFormat == PIXELFORMAT_RGBA8;
|
||||
}
|
||||
|
||||
FormatHandler::DecodedImage STBHandler::decode(love::filesystem::FileData *data)
|
||||
FormatHandler::DecodedImage STBHandler::decode(Data *data)
|
||||
{
|
||||
DecodedImage img;
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ public:
|
||||
|
||||
// Implements FormatHandler.
|
||||
|
||||
bool canDecode(love::filesystem::FileData *data) override;
|
||||
bool canDecode(Data *data) override;
|
||||
bool canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat) override;
|
||||
|
||||
DecodedImage decode(love::filesystem::FileData *data) override;
|
||||
DecodedImage decode(Data *data) override;
|
||||
EncodedImage encode(const DecodedImage &img, EncodedFormat format) override;
|
||||
|
||||
void free(unsigned char *mem) override;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
**/
|
||||
|
||||
#include "ddsHandler.h"
|
||||
#include "common/Exception.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -27,12 +28,12 @@ namespace image
|
||||
namespace magpie
|
||||
{
|
||||
|
||||
bool DDSHandler::canParse(const filesystem::FileData *data)
|
||||
bool DDSHandler::canParse(const Data *data)
|
||||
{
|
||||
return dds::isCompressedDDS(data->getData(), data->getSize());
|
||||
}
|
||||
|
||||
StrongRef<CompressedMemory> DDSHandler::parse(filesystem::FileData *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<CompressedMemory> DDSHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
{
|
||||
if (!dds::isDDS(filedata->getData(), filedata->getSize()))
|
||||
throw love::Exception("Could not decode compressed data (not a DDS file?)");
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
virtual ~DDSHandler() {}
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
bool canParse(const filesystem::FileData *data) override;
|
||||
bool canParse(const Data *data) override;
|
||||
|
||||
StrongRef<CompressedMemory> parse(filesystem::FileData *filedata,
|
||||
StrongRef<CompressedMemory> parse(Data *filedata,
|
||||
std::vector<StrongRef<CompressedSlice>> &images,
|
||||
PixelFormat &format, bool &sRGB) override;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
**/
|
||||
|
||||
#include "wrap_Image.h"
|
||||
|
||||
#include "common/wrap_Data.h"
|
||||
#include "common/Data.h"
|
||||
#include "common/StringMap.h"
|
||||
|
||||
@@ -77,9 +77,9 @@ int w_newImageData(lua_State *L)
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
else if (filesystem::luax_cangetfiledata(L, 1)) // Case 2: File(Data).
|
||||
else if (filesystem::luax_cangetfiledata(L, 1) || luax_istype(L, 1, Data::type)) // Case 2: File(Data).
|
||||
{
|
||||
filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
|
||||
Data *data = love::filesystem::luax_getdata(L, 1);
|
||||
|
||||
ImageData *t = nullptr;
|
||||
luax_catchexcept(L,
|
||||
@@ -99,7 +99,7 @@ int w_newImageData(lua_State *L)
|
||||
|
||||
int w_newCompressedData(lua_State *L)
|
||||
{
|
||||
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
|
||||
Data *data = love::filesystem::luax_getdata(L, 1);
|
||||
|
||||
CompressedImageData *t = nullptr;
|
||||
luax_catchexcept(L,
|
||||
@@ -114,7 +114,7 @@ int w_newCompressedData(lua_State *L)
|
||||
|
||||
int w_isCompressed(lua_State *L)
|
||||
{
|
||||
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
|
||||
Data *data = love::filesystem::luax_getdata(L, 1);
|
||||
bool compressed = instance()->isCompressed(data);
|
||||
data->release();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user