screenshot.c
changeset 3329 9885789ecaf7
parent 3294 6aab2bd8b924
child 4019 05b2ea531da0
equal deleted inserted replaced
3328:dd9039526687 3329:9885789ecaf7
     5 #include "debug.h"
     5 #include "debug.h"
     6 #include "functions.h"
     6 #include "functions.h"
     7 #include "strings.h"
     7 #include "strings.h"
     8 #include "table/strings.h"
     8 #include "table/strings.h"
     9 #include "gfx.h"
     9 #include "gfx.h"
       
    10 #include "hal.h"
    10 #include "viewport.h"
    11 #include "viewport.h"
    11 #include "player.h"
    12 #include "player.h"
    12 #include "screenshot.h"
    13 #include "screenshot.h"
    13 #include "variables.h"
    14 #include "variables.h"
    14 
       
    15 #if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
       
    16 extern const char *convert_to_fs_charset(const char *filename);
       
    17 #else
       
    18 #define convert_to_fs_charset(str) (str)
       
    19 #endif
       
    20 
    15 
    21 char _screenshot_format_name[8];
    16 char _screenshot_format_name[8];
    22 uint _num_screenshot_formats;
    17 uint _num_screenshot_formats;
    23 uint _cur_screenshot_format;
    18 uint _cur_screenshot_format;
    24 
    19 
    77 
    72 
    78 	// only implemented for 8bit images so far.
    73 	// only implemented for 8bit images so far.
    79 	if (pixelformat != 8)
    74 	if (pixelformat != 8)
    80 		return false;
    75 		return false;
    81 
    76 
    82 	f = fopen(convert_to_fs_charset(name), "wb");
    77 	f = fopen(OTTD2FS(name), "wb");
    83 	if (f == NULL) return false;
    78 	if (f == NULL) return false;
    84 
    79 
    85 	// each scanline must be aligned on a 32bit boundary
    80 	// each scanline must be aligned on a 32bit boundary
    86 	padw = ALIGN(w, 4);
    81 	padw = ALIGN(w, 4);
    87 
    82 
   181 
   176 
   182 	// only implemented for 8bit images so far.
   177 	// only implemented for 8bit images so far.
   183 	if (pixelformat != 8)
   178 	if (pixelformat != 8)
   184 		return false;
   179 		return false;
   185 
   180 
   186 	f = fopen(convert_to_fs_charset(name), "wb");
   181 	f = fopen(OTTD2FS(name), "wb");
   187 	if (f == NULL) return false;
   182 	if (f == NULL) return false;
   188 
   183 
   189 	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (char *)name, png_my_error, png_my_warning);
   184 	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (char *)name, png_my_error, png_my_warning);
   190 
   185 
   191 	if (png_ptr == NULL) {
   186 	if (png_ptr == NULL) {
   292 	PcxHeader pcx;
   287 	PcxHeader pcx;
   293 
   288 
   294 	if (pixelformat != 8 || w == 0)
   289 	if (pixelformat != 8 || w == 0)
   295 		return false;
   290 		return false;
   296 
   291 
   297 	f = fopen(convert_to_fs_charset(name), "wb");
   292 	f = fopen(OTTD2FS(name), "wb");
   298 	if (f == NULL) return false;
   293 	if (f == NULL) return false;
   299 
   294 
   300 	memset(&pcx, 0, sizeof(pcx));
   295 	memset(&pcx, 0, sizeof(pcx));
   301 
   296 
   302 	// setup pcx header
   297 	// setup pcx header