mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Cleaned up some ImageData code.
This commit is contained in:
@@ -42,7 +42,7 @@ bool FormatHandler::canDecode(love::filesystem::FileData* /*data*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FormatHandler::canEncode(ImageData::Format /*format*/)
|
||||
bool FormatHandler::canEncode(ImageData::EncodedFormat /*format*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ FormatHandler::DecodedImage FormatHandler::decode(love::filesystem::FileData* /*
|
||||
throw love::Exception("Image decoding is not implemented for this format backend.");
|
||||
}
|
||||
|
||||
FormatHandler::EncodedImage FormatHandler::encode(const DecodedImage& /*img*/, ImageData::Format /*format*/)
|
||||
FormatHandler::EncodedImage FormatHandler::encode(const DecodedImage& /*img*/, ImageData::EncodedFormat /*format*/)
|
||||
{
|
||||
throw love::Exception("Image encoding is not implemented for this format backend.");
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* Whether this format handler can encode to a particular format.
|
||||
**/
|
||||
virtual bool canEncode(ImageData::Format format);
|
||||
virtual bool canEncode(ImageData::EncodedFormat format);
|
||||
|
||||
/**
|
||||
* Decodes an image from its encoded form into raw pixel data.
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
* @param format The format to encode to.
|
||||
* @return The encoded image data.
|
||||
**/
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::Format format);
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::EncodedFormat format);
|
||||
|
||||
/**
|
||||
* Frees memory allocated by the format handler.
|
||||
|
||||
@@ -141,7 +141,7 @@ void ImageData::decode(love::filesystem::FileData *data)
|
||||
decodeHandler = decoder;
|
||||
}
|
||||
|
||||
void ImageData::encode(love::filesystem::File *f, ImageData::Format format)
|
||||
void ImageData::encode(love::filesystem::File *f, ImageData::EncodedFormat format)
|
||||
{
|
||||
FormatHandler *encoder = nullptr;
|
||||
FormatHandler::EncodedImage encodedimage;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
virtual ~ImageData();
|
||||
|
||||
// Implements image::ImageData.
|
||||
virtual void encode(love::filesystem::File *f, ImageData::Format format);
|
||||
virtual void encode(love::filesystem::File *f, ImageData::EncodedFormat format);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -140,9 +140,9 @@ bool PNGHandler::canDecode(love::filesystem::FileData *data)
|
||||
return status == 0 && width > 0 && height > 0;
|
||||
}
|
||||
|
||||
bool PNGHandler::canEncode(ImageData::Format format)
|
||||
bool PNGHandler::canEncode(ImageData::EncodedFormat format)
|
||||
{
|
||||
return format == ImageData::FORMAT_PNG;
|
||||
return format == ImageData::ENCODED_PNG;
|
||||
}
|
||||
|
||||
PNGHandler::DecodedImage PNGHandler::decode(love::filesystem::FileData *fdata)
|
||||
@@ -176,9 +176,9 @@ PNGHandler::DecodedImage PNGHandler::decode(love::filesystem::FileData *fdata)
|
||||
return img;
|
||||
}
|
||||
|
||||
PNGHandler::EncodedImage PNGHandler::encode(const DecodedImage &img, ImageData::Format format)
|
||||
PNGHandler::EncodedImage PNGHandler::encode(const DecodedImage &img, ImageData::EncodedFormat format)
|
||||
{
|
||||
if (format != ImageData::FORMAT_PNG)
|
||||
if (format != ImageData::ENCODED_PNG)
|
||||
throw love::Exception("PNG encoder cannot encode to non-PNG format.");
|
||||
|
||||
EncodedImage encimg;
|
||||
|
||||
@@ -41,10 +41,10 @@ public:
|
||||
// Implements FormatHandler.
|
||||
|
||||
virtual bool canDecode(love::filesystem::FileData *data);
|
||||
virtual bool canEncode(ImageData::Format format);
|
||||
virtual bool canEncode(ImageData::EncodedFormat format);
|
||||
|
||||
virtual DecodedImage decode(love::filesystem::FileData *data);
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::Format format);
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::EncodedFormat format);
|
||||
|
||||
virtual void free(unsigned char *mem);
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ bool STBHandler::canDecode(love::filesystem::FileData *data)
|
||||
return status == 1 && w > 0 && h > 0;
|
||||
}
|
||||
|
||||
bool STBHandler::canEncode(ImageData::Format format)
|
||||
bool STBHandler::canEncode(ImageData::EncodedFormat format)
|
||||
{
|
||||
return format == ImageData::FORMAT_TGA;
|
||||
return format == ImageData::ENCODED_TGA;
|
||||
}
|
||||
|
||||
FormatHandler::DecodedImage STBHandler::decode(love::filesystem::FileData *data)
|
||||
@@ -82,7 +82,7 @@ FormatHandler::DecodedImage STBHandler::decode(love::filesystem::FileData *data)
|
||||
return img;
|
||||
}
|
||||
|
||||
FormatHandler::EncodedImage STBHandler::encode(const DecodedImage &img, ImageData::Format format)
|
||||
FormatHandler::EncodedImage STBHandler::encode(const DecodedImage &img, ImageData::EncodedFormat format)
|
||||
{
|
||||
if (!canEncode(format))
|
||||
throw love::Exception("Invalid format.");
|
||||
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
// Implements FormatHandler.
|
||||
|
||||
virtual bool canDecode(love::filesystem::FileData *data);
|
||||
virtual bool canEncode(ImageData::Format format);
|
||||
virtual bool canEncode(ImageData::EncodedFormat format);
|
||||
|
||||
virtual DecodedImage decode(love::filesystem::FileData *data);
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::Format format);
|
||||
virtual EncodedImage encode(const DecodedImage &img, ImageData::EncodedFormat format);
|
||||
|
||||
virtual void free(unsigned char *mem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user