Merge branch 'bug_617_default_favlist_handling_fix' into experimental
[vuplus_dvbapp] / lib / gdi / picload.cpp
index 375f33f..0ce10c0 100644 (file)
@@ -1,4 +1,5 @@
-#include <png.h>       // must be included before Python.h because of setjmp
+#define PNG_SKIP_SETJMP_CHECK
+#include <png.h>
 #include <fcntl.h>
 
 #include <lib/gdi/picload.h>
@@ -288,24 +289,12 @@ static unsigned char *png_load(const char *file, int *ox, int *oy)
        png_read_info(png_ptr, info_ptr);
        png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
 
-       if (color_type == PNG_COLOR_TYPE_PALETTE)
-       {
-               png_set_palette_to_rgb(png_ptr);
-               png_set_background(png_ptr, (png_color_16 *)&my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-       }
-       if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-       {
-               png_set_gray_to_rgb(png_ptr);
-               png_set_background(png_ptr, (png_color_16 *)&my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-       }
-       if (color_type & PNG_COLOR_MASK_ALPHA)
-               png_set_strip_alpha(png_ptr);
-
-       if (bit_depth < 8)
-               png_set_packing(png_ptr);
-
+       if ((color_type == PNG_COLOR_TYPE_PALETTE)||(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)||(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
+               png_set_expand(png_ptr);
        if (bit_depth == 16)
                png_set_strip_16(png_ptr);
+       if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+               png_set_gray_to_rgb(png_ptr);
 
        int number_passes = png_set_interlace_handling(png_ptr);
        png_read_update_info(png_ptr, info_ptr);
@@ -1015,12 +1004,12 @@ RESULT ePicLoad::setPara(PyObject *val)
                return 0;
        else {
                ePyObject fast = PySequence_Fast(val, "");
-               m_conf.max_x            = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 0));
-               m_conf.max_y            = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 1));
-               m_conf.aspect_ratio     = (double)PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 2)) / PyInt_AsLong(PySequence_Fast_GET_ITEM(val, 3));
-               m_conf.usecache         = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 4));
-               m_conf.resizetype       = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 5));
-               const char *bg_str      = PyString_AsString( PySequence_Fast_GET_ITEM(val, 6));
+               m_conf.max_x            = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 0));
+               m_conf.max_y            = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 1));
+               m_conf.aspect_ratio     = (double)PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 2)) / PyInt_AsLong(PySequence_Fast_GET_ITEM(fast, 3));
+               m_conf.usecache         = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 4));
+               m_conf.resizetype       = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 5));
+               const char *bg_str      = PyString_AsString( PySequence_Fast_GET_ITEM(fast, 6));
        
                if(bg_str[0] == '#' && strlen(bg_str)==9)
                {