X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FImageIO.cpp;h=3e6a72e825fc2caf89411e692e27a6b02618f9c8;hb=c5dc3750efbc615b70917f19bb95cbd352cd00f6;hp=c8dffe511d1537a9e21b771db0f2185dee8e56c3;hpb=97989f58ab13c64fbe05e629d2b2a024a2c3cfa4;p=lugaru.git diff --git a/Source/ImageIO.cpp b/Source/ImageIO.cpp index c8dffe5..3e6a72e 100644 --- a/Source/ImageIO.cpp +++ b/Source/ImageIO.cpp @@ -1,5 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games +Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -26,8 +27,8 @@ along with Lugaru. If not, see . #include "Game.h" #include "ImageIO.h" +#include "Utils/Folders.h" -extern ImageRec texture; extern bool visibleloading; /* These two are needed for screenshot */ @@ -38,9 +39,15 @@ static bool load_png(const char * fname, ImageRec & tex); 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) @@ -68,7 +75,7 @@ bool save_screenshot(const char *file_name) 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"); @@ -148,7 +155,7 @@ static bool load_png(const char *file_name, ImageRec &tex) 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); @@ -285,6 +292,6 @@ save_png_done: if (fp) fclose(fp); if (!retval) - unlink(ConvertFileName(file_name)); + unlink(file_name); return retval; }