diff --git a/src/modules/image/ImageData.cpp b/src/modules/image/ImageData.cpp index 030e43c89..6f8277e49 100644 --- a/src/modules/image/ImageData.cpp +++ b/src/modules/image/ImageData.cpp @@ -74,7 +74,7 @@ void ImageData::setPixel(int x, int y, pixel c) pixels[y*getWidth()+x] = c; } -void ImageData::setPixelUnsafe(int x, int y, love::image::pixel c) +void ImageData::setPixelUnsafe(int x, int y, pixel c) { if (!inside(x, y)) throw love::Exception("Attempt to set out-of-range pixel!"); @@ -162,23 +162,23 @@ love::thread::Mutex *ImageData::getMutex() const return mutex; } -bool ImageData::getConstant(const char *in, ImageData::Format &out) +bool ImageData::getConstant(const char *in, EncodedFormat &out) { - return formats.find(in, out); + return encodedFormats.find(in, out); } -bool ImageData::getConstant(ImageData::Format in, const char *&out) +bool ImageData::getConstant(EncodedFormat in, const char *&out) { - return formats.find(in, out); + return encodedFormats.find(in, out); } -StringMap::Entry ImageData::formatEntries[] = +StringMap::Entry ImageData::encodedFormatEntries[] = { - {"tga", ImageData::FORMAT_TGA}, - {"png", ImageData::FORMAT_PNG}, + {"tga", ENCODED_TGA}, + {"png", ENCODED_PNG}, }; -StringMap ImageData::formats(ImageData::formatEntries, sizeof(ImageData::formatEntries)); +StringMap ImageData::encodedFormats(ImageData::encodedFormatEntries, sizeof(ImageData::encodedFormatEntries)); } // image } // love diff --git a/src/modules/image/ImageData.h b/src/modules/image/ImageData.h index 7a16bda02..af4b67cfc 100644 --- a/src/modules/image/ImageData.h +++ b/src/modules/image/ImageData.h @@ -47,23 +47,16 @@ class ImageData : public Data { public: - enum Format + enum EncodedFormat { - FORMAT_TGA, - FORMAT_PNG, - FORMAT_MAX_ENUM + ENCODED_TGA, + ENCODED_PNG, + ENCODED_MAX_ENUM }; ImageData(); - - /** - * Destructor. - **/ virtual ~ImageData(); - static bool getConstant(const char *in, Format &out); - static bool getConstant(Format in, const char *&out); - /** * Paste part of one ImageData onto another. The subregion defined by the top-left * corner (sx, sy) and the size (sw,sh) will be pasted to (dx,dy) in this ImageData. @@ -122,7 +115,7 @@ public: * @param f The file to save the encoded image data to. * @param format The format of the encoded data. **/ - virtual void encode(love::filesystem::File *f, Format format) = 0; + virtual void encode(love::filesystem::File *f, EncodedFormat format) = 0; love::thread::Mutex *getMutex() const; @@ -130,6 +123,9 @@ public: virtual void *getData() const; virtual size_t getSize() const; + static bool getConstant(const char *in, EncodedFormat &out); + static bool getConstant(EncodedFormat in, const char *&out); + protected: // The width of the image data. @@ -148,8 +144,8 @@ protected: private: - static StringMap::Entry formatEntries[]; - static StringMap formats; + static StringMap::Entry encodedFormatEntries[]; + static StringMap encodedFormats; }; // ImageData diff --git a/src/modules/image/magpie/FormatHandler.cpp b/src/modules/image/magpie/FormatHandler.cpp index 55781fec4..c34bf7da6 100644 --- a/src/modules/image/magpie/FormatHandler.cpp +++ b/src/modules/image/magpie/FormatHandler.cpp @@ -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."); } diff --git a/src/modules/image/magpie/FormatHandler.h b/src/modules/image/magpie/FormatHandler.h index e3b1d45ad..20e3f73f0 100644 --- a/src/modules/image/magpie/FormatHandler.h +++ b/src/modules/image/magpie/FormatHandler.h @@ -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. diff --git a/src/modules/image/magpie/ImageData.cpp b/src/modules/image/magpie/ImageData.cpp index b40a3ee24..3efec4ac4 100644 --- a/src/modules/image/magpie/ImageData.cpp +++ b/src/modules/image/magpie/ImageData.cpp @@ -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; diff --git a/src/modules/image/magpie/ImageData.h b/src/modules/image/magpie/ImageData.h index c8dbc9459..181b3a67a 100644 --- a/src/modules/image/magpie/ImageData.h +++ b/src/modules/image/magpie/ImageData.h @@ -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: diff --git a/src/modules/image/magpie/PNGHandler.cpp b/src/modules/image/magpie/PNGHandler.cpp index 314ff847a..5dacd0f72 100644 --- a/src/modules/image/magpie/PNGHandler.cpp +++ b/src/modules/image/magpie/PNGHandler.cpp @@ -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; diff --git a/src/modules/image/magpie/PNGHandler.h b/src/modules/image/magpie/PNGHandler.h index 0b6d1a771..f8af808f7 100644 --- a/src/modules/image/magpie/PNGHandler.h +++ b/src/modules/image/magpie/PNGHandler.h @@ -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); diff --git a/src/modules/image/magpie/STBHandler.cpp b/src/modules/image/magpie/STBHandler.cpp index dfd3f6caa..44f8ad46c 100644 --- a/src/modules/image/magpie/STBHandler.cpp +++ b/src/modules/image/magpie/STBHandler.cpp @@ -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."); diff --git a/src/modules/image/magpie/STBHandler.h b/src/modules/image/magpie/STBHandler.h index ec4b9e3f0..962d6b655 100644 --- a/src/modules/image/magpie/STBHandler.h +++ b/src/modules/image/magpie/STBHandler.h @@ -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); diff --git a/src/modules/image/wrap_ImageData.cpp b/src/modules/image/wrap_ImageData.cpp index bbaf03f74..850f48573 100644 --- a/src/modules/image/wrap_ImageData.cpp +++ b/src/modules/image/wrap_ImageData.cpp @@ -240,7 +240,7 @@ int w_ImageData_encode(lua_State *L) { std::string ext; const char *fmt; - ImageData::Format format = ImageData::FORMAT_MAX_ENUM; + ImageData::EncodedFormat format = ImageData::ENCODED_MAX_ENUM; ImageData *t = luax_checkimagedata(L, 1); if (lua_isstring(L, 2))