Commits

Bill Meltsner committed 3ec6c49

Removed EncodedImageData, added three new encoded image formats, and changed the way screenshots work - saving screenshots will be broken until we have some way of flipping ImageData, though

Comments (0)

Files changed (14)

platform/macosx/love.xcodeproj/project.pbxproj

 		A93E6E5410420B57007D418B /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5210420B57007D418B /* SDL.framework */; };
 		A93E6E5510420B57007D418B /* Lua.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5310420B57007D418B /* Lua.framework */; };
 		A93E6EED10420BA8007D418B /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; };
-		A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */; };
 		A946D67F104248DA002BF36C /* Reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69EA10420ABF007D418B /* Reference.cpp */; };
 		A946D680104248DA002BF36C /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E310420ABF007D418B /* Matrix.cpp */; };
 		A946D681104248DA002BF36C /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E810420ABF007D418B /* Object.cpp */; };
 		A968F0DE1083AA6600A895AA /* Joint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A968F0DC1083AA6600A895AA /* Joint.cpp */; };
 		A986DEB5113249A800810279 /* Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A986DEB1113249A800810279 /* Thread.cpp */; };
 		A986DEB6113249A800810279 /* wrap_Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A986DEB3113249A800810279 /* wrap_Thread.cpp */; };
-		A98D914410507C97008E03F2 /* EncodedImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A98D914310507C97008E03F2 /* EncodedImageData.cpp */; };
 		A9B4BA9C1045937F001DBC80 /* ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9B4BA9A1045937F001DBC80 /* ParticleSystem.cpp */; };
 		A9B4BA9D1045937F001DBC80 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9B4BA9B1045937F001DBC80 /* wrap_ParticleSystem.cpp */; };
 		A9BD60741226C988007DEC63 /* Framebuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9BD60701226C988007DEC63 /* Framebuffer.cpp */; };
 		A944D58D13244E5D0039937C /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = core.h; sourceTree = "<group>"; };
 		A944D58E13244E5D0039937C /* unchecked.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unchecked.h; sourceTree = "<group>"; };
 		A944D58F13244E5D0039937C /* utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utf8.h; sourceTree = "<group>"; };
-		A946CE801172BCD6005E1462 /* wrap_EncodedImageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_EncodedImageData.h; sourceTree = "<group>"; };
-		A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_EncodedImageData.cpp; sourceTree = "<group>"; };
 		A946D4421176AC42005E1462 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = "<group>"; };
 		A95684F5125D3555001B276B /* b64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b64.cpp; sourceTree = "<group>"; };
 		A95684F6125D3555001B276B /* b64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b64.h; sourceTree = "<group>"; };
 		A986DEB2113249A800810279 /* Thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Thread.h; sourceTree = "<group>"; };
 		A986DEB3113249A800810279 /* wrap_Thread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Thread.cpp; sourceTree = "<group>"; };
 		A986DEB4113249A800810279 /* wrap_Thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Thread.h; sourceTree = "<group>"; };
-		A98D913E10507BF9008E03F2 /* EncodedImageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EncodedImageData.h; sourceTree = "<group>"; };
-		A98D914310507C97008E03F2 /* EncodedImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EncodedImageData.cpp; sourceTree = "<group>"; };
 		A9B1AE451197293000D496EB /* love_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = love_Prefix.pch; sourceTree = "<group>"; };
 		A9B4BA981045937F001DBC80 /* ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleSystem.h; sourceTree = "<group>"; };
 		A9B4BA991045937F001DBC80 /* wrap_ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_ParticleSystem.h; sourceTree = "<group>"; };
 			isa = PBXGroup;
 			children = (
 				A93E6AA810420AC3007D418B /* devil */,
-				A98D914310507C97008E03F2 /* EncodedImageData.cpp */,
-				A98D913E10507BF9008E03F2 /* EncodedImageData.h */,
 				A93E6AAD10420AC3007D418B /* Image.h */,
 				A93E6AAE10420AC3007D418B /* ImageData.cpp */,
 				A93E6AAF10420AC3007D418B /* ImageData.h */,
-				A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */,
-				A946CE801172BCD6005E1462 /* wrap_EncodedImageData.h */,
 				A93E6AB010420AC3007D418B /* wrap_Image.cpp */,
 				A93E6AB110420AC3007D418B /* wrap_Image.h */,
 				A93E6AB210420AC3007D418B /* wrap_ImageData.cpp */,
 				A9255DEC1043188D00BA1496 /* SDLMain.m in Sources */,
 				A9B4BA9C1045937F001DBC80 /* ParticleSystem.cpp in Sources */,
 				A9B4BA9D1045937F001DBC80 /* wrap_ParticleSystem.cpp in Sources */,
-				A98D914410507C97008E03F2 /* EncodedImageData.cpp in Sources */,
 				A968F0CF1083A9A900A895AA /* Event.cpp in Sources */,
 				A968F0D11083A9B900A895AA /* File.cpp in Sources */,
 				A968F0D31083A9D400A895AA /* Graphics.cpp in Sources */,
 				A93A3AB51121E86E003B04A4 /* Image.cpp in Sources */,
 				A986DEB5113249A800810279 /* Thread.cpp in Sources */,
 				A986DEB6113249A800810279 /* wrap_Thread.cpp in Sources */,
-				A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */,
 				A9BD60741226C988007DEC63 /* Framebuffer.cpp in Sources */,
 				A9BD60751226C988007DEC63 /* wrap_Framebuffer.cpp in Sources */,
 				A95684F7125D3555001B276B /* b64.cpp in Sources */,

src/common/runtime.cpp

 
 		// Image
 		{"ImageData", IMAGE_IMAGE_DATA_ID},
-		{"EncodedImageData", IMAGE_ENCODED_IMAGE_DATA_ID},
 
 		// Audio
 		{"Source", AUDIO_SOURCE_ID},

src/modules/image/EncodedImageData.cpp

-/**
- * Copyright (c) 2006-2011 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#include "EncodedImageData.h"
-
-namespace love
-{
-namespace image
-{
-	EncodedImageData::EncodedImageData(void * d, Format f, int s)
-		: data(d), size(s), format(f), freeData(0)
-	{
-	}
-
-	EncodedImageData::EncodedImageData(void * d, Format f, int s, void (*freeData)(void*))
-		: data(d), size(s), format(f), freeData(freeData)
-	{
-	}
-
-	EncodedImageData::~EncodedImageData()
-	{
-		if (freeData != 0)
-			freeData(data);
-	}
-
-	void * EncodedImageData::getData() const
-	{
-		return data;
-	}
-
-	EncodedImageData::Format EncodedImageData::getFormat() const
-	{
-		return format;
-	}
-
-	int EncodedImageData::getSize() const
-	{
-		return size;
-	}
-
-	bool EncodedImageData::getConstant(const char * in, EncodedImageData::Format & out)
-	{
-		return formats.find(in, out);
-	}
-
-	bool EncodedImageData::getConstant(EncodedImageData::Format in, const char *& out)
-	{
-		return formats.find(in, out);
-	}
-
-	StringMap<EncodedImageData::Format, EncodedImageData::FORMAT_MAX_ENUM>::Entry EncodedImageData::formatEntries[] =
-	{
-		{"tga", EncodedImageData::FORMAT_TGA},
-		{"bmp", EncodedImageData::FORMAT_BMP},
-	};
-
-	StringMap<EncodedImageData::Format, EncodedImageData::FORMAT_MAX_ENUM> EncodedImageData::formats(EncodedImageData::formatEntries, sizeof(EncodedImageData::formatEntries));
-
-} // image
-} // love

src/modules/image/EncodedImageData.h

-/**
- * Copyright (c) 2006-2011 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#ifndef LOVE_IMAGE_ENCODED_IMAGE_DATA_H
-#define LOVE_IMAGE_ENCODED_IMAGE_DATA_H
-
-// LOVE
-#include <common/Data.h>
-#include <common/StringMap.h>
-
-namespace love
-{
-namespace image
-{
-	/**
-	 * Represents encoded pixel data.
-	 **/
-	class EncodedImageData : public Data
-	{
-	public:
-
-		enum Format
-		{
-			FORMAT_TGA = 1,
-			FORMAT_BMP,
-			FORMAT_MAX_ENUM
-		};
-
-		/**
-		* Constructor.
-		**/
-		EncodedImageData(void * data, Format format, int size);
-		EncodedImageData(void * data, Format format, int size, void (*freeData)(void*));
-
-		/**
-		* Destructor.
-		**/
-		virtual ~EncodedImageData();
-
-		// Implements Data.
-		void * getData() const;
-		int getSize() const;
-
-		/**
-		* Get the format the data is encoded in.
-		**/
-		Format getFormat() const;
-
-		static bool getConstant(const char * in, Format & out);
-		static bool getConstant(Format in, const char *& out);
-
-	private:
-
-		/**
-		* Actual data.
-		**/
-		void * data;
-
-		/**
-		* Size of the data.
-		**/
-		int size;
-
-		/**
-		 * Image format.
-		 **/
-		Format format;
-
-		static StringMap<Format, FORMAT_MAX_ENUM>::Entry formatEntries[];
-		static StringMap<Format, FORMAT_MAX_ENUM> formats;
-
-		void (*freeData)(void *data);
-
-	}; // EncodedImageData
-
-} // image
-} // love
-
-#endif // LOVE_IMAGE_ENCODED_IMAGE_DATA_H

src/modules/image/ImageData.cpp

 	{
 		return (x >= 0 && x < getWidth() && y >= 0 && y < getHeight());
 	}
+	
+	bool ImageData::getConstant(const char * in, ImageData::Format & out)
+	{
+		return formats.find(in, out);
+	}
+	
+	bool ImageData::getConstant(ImageData::Format in, const char *& out)
+	{
+		return formats.find(in, out);
+	}
+	
+	StringMap<ImageData::Format, ImageData::FORMAT_MAX_ENUM>::Entry ImageData::formatEntries[] =
+	{
+		{"tga", ImageData::FORMAT_TGA},
+		{"bmp", ImageData::FORMAT_BMP},
+		{"gif", ImageData::FORMAT_GIF},
+		{"jpg", ImageData::FORMAT_JPG},
+		{"png", ImageData::FORMAT_PNG},
+	};
+	
+	StringMap<ImageData::Format, ImageData::FORMAT_MAX_ENUM> ImageData::formats(ImageData::formatEntries, sizeof(ImageData::formatEntries));
 
 } // image
 } // love

src/modules/image/ImageData.h

 
 // LOVE
 #include <common/Data.h>
-
-#include "EncodedImageData.h"
+#include <filesystem/File.h>
 
 namespace love
 {	
 	class ImageData : public Data
 	{
 	public:
+		
+		enum Format
+		{
+			FORMAT_TGA = 1,
+			FORMAT_BMP,
+			FORMAT_GIF,
+			FORMAT_JPG,
+			FORMAT_PNG,
+			FORMAT_MAX_ENUM
+		};
 
 		/**
 		* 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
 		 * @param f The format to convert to.
 		 * @return A pointer to the encoded image data.
 		 **/
-		virtual EncodedImageData * encode(EncodedImageData::Format f) = 0;
+		virtual void encode(love::filesystem::File * f, Format format) = 0;
+		
+	private:
+		static StringMap<Format, FORMAT_MAX_ENUM>::Entry formatEntries[];
+		static StringMap<Format, FORMAT_MAX_ENUM> formats;
 
 	}; // ImageData
 

src/modules/image/devil/ImageData.cpp

 
 // LOVE
 #include <common/Exception.h>
+#include <filesystem/File.h>
 
 namespace love
 {
 		return pixels[y*width+x];
 	}
 
-	EncodedImageData * ImageData::encode(EncodedImageData::Format f) {
+	void ImageData::encode(love::filesystem::File * f, ImageData::Format format) {
 		ilBindImage(image);
-		ILubyte * data;
-		ILuint w = getWidth();
-		int h = getHeight(); // has to be a signed int so we can make it negative for BMPs
-		int headerLen, bpp, row, size, padding, filesize;
-		switch (f) {
-			case EncodedImageData::FORMAT_BMP:
-				headerLen = 54;
-				bpp = 3;
-				row = w * bpp;
-				padding = row & 3;
-				size = h * (row + padding);
-				filesize = size + headerLen;
-				data = new ILubyte[filesize];
-				// Here's the header for the BMP file format.
-				data[0] = 66; // "B"
-				data[1] = 77; // "M"
-				data[2] = filesize & 255; // size of the file
-				data[3] = (filesize >> 8) & 255;
-				data[4] = (filesize >> 16) & 255;
-				data[5] = (filesize >> 24) & 255;
-				data[6] = data[7] = data[8] = data[9] = 0; // useless reserved values
-				data[10] = headerLen; // offset where pixel data begins
-				data[11] = (headerLen >> 8) & 255;
-				data[12] = (headerLen >> 16) & 255;
-				data[13] = (headerLen >> 24) & 255;
-				data[14] = headerLen - 14; // length of this part of the header
-				data[15] = ((headerLen - 14) >> 8) & 255;
-				data[16] = ((headerLen - 14) >> 16) & 255;
-				data[17] = ((headerLen - 14) >> 24) & 255;
-				data[18] = w & 255; // width of the bitmap
-				data[19] = (w >> 8) & 255;
-				data[20] = (w >> 16) & 255;
-				data[21] = (w >> 24) & 255;
-				data[22] = -h & 255; // negative height of the bitmap - used so we don't have to flip the data
-				data[23] = ((-h) >> 8) & 255;
-				data[24] = ((-h) >> 16) & 255;
-				data[25] = ((-h) >> 24) & 255;
-				data[26] = 1; // number of color planes
-				data[27] = 0;
-				data[28] = bpp * 8; // bits per pixel
-				data[29] = 0;
-				data[30] = data[31] = data[32] = data[33] = 0; // RGB - no compression
-				data[34] = (row + padding) * h; // length of the pixel data
-				data[35] = (((row + padding) * h) >> 8) & 255;
-				data[36] = (((row + padding) * h) >> 16) & 255;
-				data[37] = (((row + padding) * h) >> 24) & 255;
-				data[38] = 2835 & 255; // horizontal pixels per meter
-				data[39] = (2835 >> 8) & 255;
-				data[40] = (2835 >> 16) & 255;
-				data[41] = (2835 >> 24) & 255;
-				data[42] = 2835 & 255; // vertical pixels per meter
-				data[43] = data[39];
-				data[44] = data[40];
-				data[45] = data[41];
-				data[46] = data[47] = data[48] = data[49] = 0; // number of colors in the palette
-				data[50] = data[51] = data[52] = data[53] = 0; // all colors are important!
-				// Okay, header's done! Now for the pixel data...
-				data += headerLen;
-				for (int i = 0; i < h; i++) { // we've got to loop through the rows, adding the pixel data plus padding
-					ilCopyPixels(0,i,0,w,1,1,IL_BGR,IL_UNSIGNED_BYTE,data);
-					data += row;
-				}
-				data -= filesize;
+		ILuint ilFormat;
+		switch (format) {
+			case ImageData::FORMAT_BMP:
+				ilFormat = IL_BMP;
 				break;
-			case EncodedImageData::FORMAT_TGA:
-			default: // TGA is the default format
-				headerLen = 18;
-				bpp = 4;
-				size = h * w * bpp;
-				data = new ILubyte[size + headerLen];
-				// here's the header for the Targa file format.
-				data[0] = 0; // ID field size
-				data[1] = 0; // colormap type
-				data[2] = 2; // image type
-				data[3] = data[4] = 0; // colormap start
-				data[5] = data[6] = 0; // colormap length
-				data[7] = 32; // colormap bits
-				data[8] = data[9] = 0; // x origin
-				data[10] = data[11] = 0; // y origin
-				// Targa is little endian, so:
-				data[12] = w & 255; // least significant byte of width
-				data[13] = w >> 8; // most significant byte of width
-				data[14] = h & 255; // least significant byte of height
-				data[15] = h >> 8; // most significant byte of height
-				data[16] = bpp * 8; // bits per pixel
-				data[17] = 0x20; // descriptor bits (flip bits: 0x10 horizontal, 0x20 vertical)
-				// header done. write the pixel data to TGA:
-				data += headerLen;
-				ilCopyPixels(0,0,0,w,h,1,IL_BGRA,IL_UNSIGNED_BYTE,data); // convert the pixels to BGRA (remember, little-endian) and copy them to data
-
-				data -= headerLen;
+			case ImageData::FORMAT_TGA:
+				ilFormat = IL_TGA;
+				break;
+			case ImageData::FORMAT_GIF:
+				ilFormat = IL_GIF;
+				break;
+			case ImageData::FORMAT_JPG:
+				ilFormat = IL_JPG;
+				break;
+			case ImageData::FORMAT_PNG:
+			default: // PNG is the default format
+				ilFormat = IL_PNG;
+				break;
 		}
-		return new EncodedImageData(data, f, size + headerLen, freeData);
-	}
-
-	void ImageData::freeData(void *data)
-	{
-		delete[] (ILubyte*) data;
+		ILuint size = ilSaveL(ilFormat, NULL, 0);
+		ILubyte * data = new ILubyte[size];
+		ilSaveL(ilFormat, data, size);
+		f->open(love::filesystem::File::WRITE);
+		f->write(data, size);
+		f->close();
+		delete[] data;
 	}
 
 } // devil

src/modules/image/devil/ImageData.h

 #include <filesystem/File.h>
 #include <image/Image.h>
 #include <image/ImageData.h>
-#include <image/EncodedImageData.h>
 
 // DevIL
 #include <IL/il.h>
 		int getHeight() const ;
 		void setPixel(int x, int y, pixel c);
 		pixel getPixel(int x, int y) const;
-		EncodedImageData * encode(EncodedImageData::Format f);
-
-		static void freeData(void *data);
+		void encode(love::filesystem::File * f, Format format);
 
 	}; // ImageData
 

src/modules/image/devil/wrap_Image.cpp

 **/
 
 #include "wrap_Image.h"
-#include "image/EncodedImageData.h"
-#include "image/wrap_EncodedImageData.h"
 
 namespace love
 {
 	// List of functions to wrap.
 	static const luaL_Reg functions[] = {
 		{ "newImageData",  w_newImageData },
-		{ "newEncodedImageData", w_newEncodedImageData },
 		{ 0, 0 }
 	};
 
 	static const lua_CFunction types[] = {
 		luaopen_imagedata,
-		luaopen_encodedimagedata,
 		0
 	};
 	

src/modules/image/wrap_EncodedImageData.cpp

-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_ImageData.h"
-
-#include <common/wrap_Data.h>
-
-namespace love
-{
-namespace image
-{
-	EncodedImageData * luax_checkencodedimagedata(lua_State * L, int idx)
-	{
-		return luax_checktype<EncodedImageData>(L, idx, "EncodedImageData", IMAGE_ENCODED_IMAGE_DATA_T);
-	}
-	
-	int w_EncodedImageData_getFormat(lua_State * L) {
-		EncodedImageData * e = luax_checkencodedimagedata(L, 1);
-		EncodedImageData::Format f = e->getFormat();
-		const char * fmt;
-		EncodedImageData::getConstant(f, fmt);
-		lua_pushstring(L, fmt);
-		return 1;
-	}
-
-	static const luaL_Reg functions[] = {
-
-		// Data
-		{ "getPointer", w_Data_getPointer },
-		{ "getSize", w_Data_getSize },
-
-		{ "getFormat", w_EncodedImageData_getFormat },
-		{ 0, 0 }
-	};
-
-	int luaopen_encodedimagedata(lua_State * L)
-	{
-		return luax_register_type(L, "EncodedImageData", functions);
-	}
-
-} // image
-} // love

src/modules/image/wrap_EncodedImageData.h

-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_IMAGE_WRAP_ENCODED_IMAGE_DATA_H
-#define LOVE_IMAGE_WRAP_ENCODED_IMAGE_DATA_H
-
-// LOVE
-#include <common/runtime.h>
-#include "ImageData.h"
-
-namespace love
-{
-namespace image
-{
-	EncodedImageData * luax_checkencodedimagedata(lua_State * L, int idx);
-	
-	int w_EncodedImageData_getFormat(lua_State * L);
-	int luaopen_encodedimagedata(lua_State * L);
-
-} // image
-} // love
-
-#endif // LOVE_IMAGE_WRAP_ENCODED_IMAGE_DATA_H

src/modules/image/wrap_Image.cpp

 
 #include "wrap_Image.h"
 
-#include "EncodedImageData.h"
-#include "wrap_EncodedImageData.h"
-
 #include <common/Data.h>
 #include <common/StringMap.h>
 
 		return 1;
 	}
 
-	int w_newEncodedImageData(lua_State * L) {
-		ImageData * t = luax_checkimagedata(L, 1);
-		const char * fmt = luaL_checkstring(L, 2);
-		EncodedImageData::Format f;
-		EncodedImageData::getConstant(fmt, f);
-		EncodedImageData * eid = t->encode(f);
-		luax_newtype(L, "EncodedImageData", IMAGE_ENCODED_IMAGE_DATA_T, (void*)eid);
-		return 1;
-	}
-
 } // image
 } // love

src/modules/image/wrap_Image.h

 {
 	int w_getFormats(lua_State * L);
 	int w_newImageData(lua_State * L);
-	int w_newEncodedImageData(lua_State * L);
 	extern "C" LOVE_EXPORT int luaopen_love_image(lua_State * L);
 
 } // image

src/modules/image/wrap_ImageData.cpp

 #include "wrap_ImageData.h"
 
 #include <common/wrap_Data.h>
+#include <filesystem/File.h>
 
 namespace love
 {
 	int w_ImageData_encode(lua_State * L)
 	{
 		ImageData * t = luax_checkimagedata(L, 1);
-		const char * fmt = luaL_checkstring(L, 2);
-		EncodedImageData::Format f;
-		EncodedImageData::getConstant(fmt, f);
-		EncodedImageData * eid = t->encode(f);
-		luax_newtype(L, "EncodedImageData", IMAGE_ENCODED_IMAGE_DATA_T, (void*)eid);
-		return 1;
+		if(lua_isstring(L, 2))
+			luax_convobj(L, 2, "filesystem", "newFile");
+		love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
+		const char * fmt;
+		if (lua_isnoneornil(L, 3)) {
+			fmt = file->getExtension().c_str();
+		} else {
+			fmt = luaL_checkstring(L, 3);
+		}
+		ImageData::Format format;
+		ImageData::getConstant(fmt, format);
+		t->encode(file, format);
+		return 0;
 	}
 
 	static const luaL_Reg functions[] = {