1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2011-11-30 21:38:37 +0000
+++ src/graphic/graphic.cc 2012-02-19 17:10:12 +0000
@@ -725,6 +725,18 @@
if (!png_ptr)
throw wexception("Graphic::save_png: could not create png struct");
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(0));
+ throw wexception("Graphic::save_png: could not create png info struct");
+ }
+
+ // Set jump for error
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ throw wexception("Graphic::save_png: Error writing PNG!");
+ }
+
// Set another write function. This is potentially dangerouse because the
// flush function is internally called by png_write_end(), this will crash
// on newer libpngs. See here:
@@ -736,35 +748,14 @@
sw,
&Graphic::m_png_write_function, &Graphic::m_png_flush_function);
- png_infop info_ptr = png_create_info_struct(png_ptr);
-
- if (!info_ptr) {
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(0));
- throw wexception("Graphic::save_png: could not create png info struct");
- }
-
- // Set jump for error
- if (setjmp(png_jmpbuf(png_ptr))) {
- png_destroy_write_struct(&png_ptr, &info_ptr);
- throw wexception("Graphic::save_png: could not set png setjmp");
- }
-
// Fill info struct
png_set_IHDR
(png_ptr, info_ptr, pix.get_w(), pix.get_h(),
8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
- // png_set_strip_16(png_ptr) ;
-
// Start writing
png_write_info(png_ptr, info_ptr);
-
- // Strip data down
- png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
-
- png_set_packing(png_ptr);
-
{
uint32_t surf_w = pix.get_w();
uint32_t surf_h = pix.get_h();
|