equal
deleted
inserted
replaced
11 #include "debug.h" |
11 #include "debug.h" |
12 #include "gfx.h" |
12 #include "gfx.h" |
13 #include "gui.h" |
13 #include "gui.h" |
14 #include "saveload.h" |
14 #include "saveload.h" |
15 #include "bmp.h" |
15 #include "bmp.h" |
|
16 #include "helpers.hpp" |
16 |
17 |
17 /** |
18 /** |
18 * Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue |
19 * Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue |
19 * (average luminosity formula) -- Dalestan |
20 * (average luminosity formula) -- Dalestan |
20 * This in fact is the NTSC Color Space -- TrueLight |
21 * This in fact is the NTSC Color Space -- TrueLight |
133 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
134 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
134 return false; |
135 return false; |
135 } |
136 } |
136 |
137 |
137 if (map != NULL) { |
138 if (map != NULL) { |
138 *map = malloc(info_ptr->width * info_ptr->height * sizeof(byte)); |
139 MallocT(/* NO & */map, info_ptr->width * info_ptr->height); |
139 |
140 |
140 if (*map == NULL) { |
141 if (*map == NULL) { |
141 ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_PNGMAP_ERROR, 0, 0); |
142 ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_PNGMAP_ERROR, 0, 0); |
142 fclose(fp); |
143 fclose(fp); |
143 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
144 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
246 fclose(f); |
247 fclose(f); |
247 BmpDestroyData(&data); |
248 BmpDestroyData(&data); |
248 return false; |
249 return false; |
249 } |
250 } |
250 |
251 |
251 *map = malloc(info.width * info.height * sizeof(byte)); |
252 MallocT(map, info.width * info.height); |
252 if (*map == NULL) { |
253 if (*map == NULL) { |
253 ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_BMPMAP_ERROR, 0, 0); |
254 ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_BMPMAP_ERROR, 0, 0); |
254 fclose(f); |
255 fclose(f); |
255 BmpDestroyData(&data); |
256 BmpDestroyData(&data); |
256 return false; |
257 return false; |