Add JPG/PNG image loading

This commit is contained in:
Joshua Granick
2014-07-08 11:35:04 -07:00
parent 9f6debd95b
commit 43f6cb0693
4 changed files with 65 additions and 11 deletions

View File

@@ -8,14 +8,12 @@ extern "C" {
#include <graphics/ImageData.h>
#include <graphics/JPEG.h>
#include <utils/ByteArray.h>
namespace lime {
extern FILE *OpenRead (const char *);
bool JPEG::Decode (const char *path, ImageData *imageData) {
struct jpeg_decompress_struct cinfo;

View File

@@ -7,14 +7,12 @@ extern "C" {
#include <graphics/ImageData.h>
#include <graphics/PNG.h>
#include <utils/ByteArray.h>
namespace lime {
extern FILE *OpenRead (const char *);
bool PNG::Decode (const char *path, ImageData *imageData) {
unsigned char png_sig[PNG_SIG_SIZE];
@@ -27,7 +25,7 @@ namespace lime {
if (!file) return false;
// verify the PNG signature
fread(png_sig, PNG_SIG_SIZE, 1, file);
int read = fread(png_sig, PNG_SIG_SIZE, 1, file);
if (png_sig_cmp (png_sig, 0, PNG_SIG_SIZE)) {
fclose (file);