1 /**
2  * Copyright (c) 2006-2016 LOVE Development Team
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty.  In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  *    claim that you wrote the original software. If you use this software
14  *    in a product, an acknowledgment in the product documentation would be
15  *    appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  *    misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  **/
20 
21 #ifndef LOVE_IMAGE_IMAGE_H
22 #define LOVE_IMAGE_IMAGE_H
23 
24 // LOVE
25 #include "common/config.h"
26 #include "common/Module.h"
27 #include "filesystem/File.h"
28 #include "ImageData.h"
29 #include "CompressedImageData.h"
30 
31 namespace love
32 {
33 namespace image
34 {
35 
36 /**
37  * This module is responsible for decoding files such as PNG, GIF, JPEG
38  * into raw pixel data, as well as parsing compressed formats which are designed
39  * to be uploaded to the GPU and rendered without being un-compressed.
40  * This module does not know how to draw images on screen; only love.graphics
41  * knows that.
42  **/
43 class Image : public Module
44 {
45 public:
46 
~Image()47 	virtual ~Image() {}
48 
49 	// Implements Module.
getModuleType()50 	virtual ModuleType getModuleType() const { return M_IMAGE; }
51 
52 	/**
53 	 * Creates new ImageData from FileData.
54 	 * @param data The FileData containing the encoded image data.
55 	 * @return The new ImageData.
56 	 **/
57 	virtual ImageData *newImageData(love::filesystem::FileData *data) = 0;
58 
59 	/**
60 	 * Creates empty ImageData with the given size.
61 	 * @param width The width of the ImageData.
62 	 * @param height The height of the ImageData.
63 	 * @return The new ImageData.
64 	 **/
65 	virtual ImageData *newImageData(int width, int height) = 0;
66 
67 	/**
68 	 * Creates empty ImageData with the given size.
69 	 * @param width The width of the ImageData.
70 	 * @param height The height of the ImageData.
71 	 * @param data The data to load into the ImageData.
72 	 * @param own Whether the new ImageData should take ownership of the data or
73 	 *        copy it.
74 	 * @return The new ImageData.
75 	 **/
76 	virtual ImageData *newImageData(int width, int height, void *data, bool own = false) = 0;
77 
78 	/**
79 	 * Creates new CompressedImageData from FileData.
80 	 * @param data The FileData containing the compressed image data.
81 	 * @return The new CompressedImageData.
82 	 **/
83 	virtual CompressedImageData *newCompressedData(love::filesystem::FileData *data) = 0;
84 
85 	/**
86 	 * Determines whether a FileData is Compressed image data or not.
87 	 * @param data The FileData to test.
88 	 **/
89 	virtual bool isCompressed(love::filesystem::FileData *data) = 0;
90 
91 }; // Image
92 
93 } // image
94 } // love
95 
96 #endif // LOVE_IMAGE_IMAGE_H
97