summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-09-18 01:35:07 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-09-18 01:35:07 +0000
commite020ca5e7f7878fb98d678e1dff180004dc27a9d (patch)
treea917e0d8d8b22ec50b4f0356605ed8e34ca62da3 /src/graphics.cpp
parent06221a4cb3f44e7532e185bc775c73741d32cbf2 (diff)
downloadmana-client-e020ca5e7f7878fb98d678e1dff180004dc27a9d.tar.gz
mana-client-e020ca5e7f7878fb98d678e1dff180004dc27a9d.tar.bz2
mana-client-e020ca5e7f7878fb98d678e1dff180004dc27a9d.tar.xz
mana-client-e020ca5e7f7878fb98d678e1dff180004dc27a9d.zip
Removed unuseful comments. Made the saveScreenshots() function return a correct value.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp93
1 files changed, 5 insertions, 88 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 1d6734c8..d5036699 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -274,98 +274,15 @@ bool Graphics::saveScreenshot()
}
testExists.close();
- ImageWriter::writePNG(getScreenshot(), pictureFilename.str());
-
- /*FILE *fp = fopen(std::string(pictureFilename.str()).c_str(), "wb");
- if (!fp)
- {
- logger->log("Could not open Screenshot's File %s in write mode.", std::string(pictureFilename.str()).c_str());
- return false;
- }
-
- png_structp png_ptr;
- png_infop info_ptr;
- png_bytep *row_pointers;
- int colortype;
-
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int rmask = 0xff000000;
- int gmask = 0x00ff0000;
- int bmask = 0x0000ff00;
- int amask = 0x000000ff;
- #else
- int rmask = 0x000000ff;
- int gmask = 0x0000ff00;
- int bmask = 0x00ff0000;
- int amask = 0xff000000;
- #endif
-
- SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE, mScreen->w,
- mScreen->h, 32, rmask, gmask, bmask, amask);
- //SDL_LockSurface(mScreen);
- SDL_BlitSurface(mScreen, NULL, surface, NULL);
- //SDL_UnlockSurface(mScreen);
-
- SDL_LockSurface(surface);
-
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
- if (!png_ptr)
+ if ( ImageWriter::writePNG(getScreenshot(), pictureFilename.str()) )
{
- logger->log("Had trouble creating png_structp");
- return false;
- }
-
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- {
- logger->log("Could not create png_info");
- return false;
- }
-
-
- if (setjmp(png_ptr->jmpbuf))
- {
- logger->log("Problem writing to %s", std::string(pictureFilename.str()).c_str());
- return false;
+ screenshotsCount++;
+ return true;
}
-
- png_init_io(png_ptr, fp);
-
- if (mScreen->format->BitsPerPixel == 24) colortype = PNG_COLOR_TYPE_RGB;
- else colortype = PNG_COLOR_TYPE_RGB_ALPHA;
-
- png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8,colortype,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- png_write_info(png_ptr, info_ptr);
-
- png_set_packing(png_ptr);
-
- row_pointers = (png_bytep*) malloc(sizeof(png_bytep)*surface->h);
- if (!row_pointers)
+ else
{
- logger->log("Had trouble converting surface to row pointers");
- return false;
+ return false;
}
-
- for (int i = 0; i < surface->h; i++)
- row_pointers[i] = (png_bytep)(Uint8 *)surface->pixels + i * surface->pitch;
-
- png_write_image(png_ptr, row_pointers);
- png_write_end(png_ptr, info_ptr);
- fclose(fp);
- if (row_pointers) free(row_pointers);
-
- if (info_ptr->palette) free(info_ptr->palette);
-
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
-
- SDL_UnlockSurface(surface);
- SDL_FreeSurface(surface);
-*/
- screenshotsCount++;
-
- return true;
}
SDL_Surface* Graphics::getScreenshot()