From 9a5a4533860ee019f92bcf96da7aa42a4d33bbc9 Mon Sep 17 00:00:00 2001 From: aerkefiende Date: Wed, 30 Mar 2011 19:08:26 +0000 Subject: [PATCH] deleting old commented code git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6170 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/main.cpp | 150 -------------------------------------------- 1 file changed, 150 deletions(-) diff --git a/source/src/main.cpp b/source/src/main.cpp index 2a78c121..0bb7666b 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -210,156 +210,6 @@ void bmp_screenshot(const char *imagepath, bool mapshot = false) // best: 100 - good: 85 [default] - bad: 70 - terrible: 50 VARP(jpegquality, 10, 85, 100); -/* -struct jpegscreenshotdest : jpeg_destination_mgr -{ - JOCTET buf[4096]; - stream *file; - - void reset() - { - next_output_byte = buf; - free_in_buffer = sizeof(buf); - } - - void flush(bool full) - { - file->write(buf, int(sizeof(buf) - (full ? 0 : free_in_buffer))); - reset(); - } - - static void inithandler(j_compress_ptr cinfo) - { - ((jpegscreenshotdest *)cinfo->dest)->reset(); - } - - static void termhandler(j_compress_ptr cinfo) - { - ((jpegscreenshotdest *)cinfo->dest)->flush(false); - } - - static boolean flushhandler(j_compress_ptr cinfo) - { - ((jpegscreenshotdest *)cinfo->dest)->flush(true); - return TRUE; - } - - jpegscreenshotdest(stream *file) : file(file) - { - init_destination = inithandler; - empty_output_buffer = flushhandler; - term_destination = termhandler; - } -}; - -struct jpegscreenshoterror : jpeg_error_mgr -{ - jmp_buf restore; - - static void exithandler(j_common_ptr cinfo) - { - longjmp(((jpegscreenshoterror *)cinfo->err)->restore, 1); - } - - static void messagehandler(j_common_ptr cinfo) - { - char buf[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buf); - conoutf("jpeg library error: %s", buf); - } - - jpegscreenshoterror() - { - jpeg_std_error(this); - error_exit = exithandler; - output_message = messagehandler; - } - - bool failed() - { - return setjmp(restore) != 0; - } -}; - -void jpeg_screenshot_____(const char *imagepath, bool mapshot = false) -{ - extern int minimaplastsize; - int iw = mapshot?minimaplastsize:screen->w; - int ih = mapshot?minimaplastsize:screen->h; - const char *filename = screenshotpath(imagepath, "jpg"); - stream *file = openfile(screenshotpath(imagepath, "jpg"), "wb"); - if(!file) { conoutf("failed to create: %s", filename); return; } - - int row_stride = 3*iw; - uchar *pixels = new uchar[row_stride*ih]; - - jpeg_compress_struct cinfo; - jpegscreenshoterror jerr; - - cinfo.err = &jerr; - if(jerr.failed()) - { - jpeg_destroy_compress(&cinfo); - delete[] pixels; - delete file; - return; - } - - jpeg_create_compress(&cinfo); - jpegscreenshotdest dest(file); - cinfo.dest = &dest; - //jpeg_stdio_dest(&cinfo, jpegfile); - - if(mapshot) - { - //conoutf("not implemented yet"); - extern GLuint minimaptex; - if(minimaptex) - { - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBindTexture(GL_TEXTURE_2D, minimaptex); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); - } - else - { - conoutf("no mapshot prepared!"); - jpeg_destroy_compress(&cinfo); - delete[] pixels; - delete file; - return; - } - - } - else - { - glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, iw, ih, GL_RGB, GL_UNSIGNED_BYTE, pixels); - } - - cinfo.image_width = iw; - cinfo.image_height = ih; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, jpegquality, TRUE); - jpeg_start_compress(&cinfo, TRUE); - const char *comment = asciiscores(true); - jpeg_write_marker(&cinfo, JPEG_COM, (JOCTET *) comment, (uint)strlen(comment)); - - while(cinfo.next_scanline < cinfo.image_height) - { - JSAMPROW row_pointer = &pixels[(cinfo.image_height-cinfo.next_scanline-1) * row_stride]; - (void) jpeg_write_scanlines(&cinfo, &row_pointer, 1); - } - - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - delete[] pixels; - delete file; -} -*/ #include "jpegenc.h"