/*
Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
This file is part of Lugaru.
#include "Game.h"
#include "ImageIO.h"
+#include "Utils/Folders.h"
-extern ImageRec texture;
extern bool visibleloading;
/* These two are needed for screenshot */
static bool load_jpg(const char * fname, ImageRec & tex);
static bool save_screenshot_png(const char * fname);
-bool upload_image(const char* fileName)
+ImageRec::ImageRec()
{
- return load_image(fileName, texture);
+ data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
+}
+
+ImageRec::~ImageRec()
+{
+ free(data);
+ data = NULL;
}
bool load_image(const char *file_name, ImageRec &tex)
const char *ptr = strrchr((char *)file_name, '.');
if (ptr) {
if (strcasecmp(ptr + 1, "png") == 0)
- return save_screenshot_png(file_name);
+ return save_screenshot_png((Folders::getScreenshotDir() + '/' + file_name).c_str());
}
STUBBED("Unsupported image type");
if (fp == NULL) {
cerr << file_name << " not found" << endl;
- return(NULL);
+ return false;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (fp)
fclose(fp);
if (!retval)
- unlink(ConvertFileName(file_name));
+ unlink(file_name);
return retval;
}