summaryrefslogtreecommitdiff
blob: 34906e98bfab249972e9ffbb5834260a6bf88677 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--- libpng-1.2.7.orig/png.h  2004-09-12 11:19:30.000000000 +0900
+++ libpng-1.2.7/png.h     2004-11-13 13:04:49.000000000 +0900
@@ -3090,7 +3092,7 @@
 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
-   png_bytep row, png_uint_32 flags));
+   png_bytep row, png_uint_32 flags, png_uint_32 transformations));
 #endif
 
 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
--- libpng-1.2.7.orig/pngrtran.c     2004-09-12 11:19:31.000000000 +0900
+++ libpng-1.2.7/pngrtran.c        2004-11-13 13:04:50.000000000 +0900
@@ -1211,7 +1211,7 @@
 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
    if (png_ptr->transformations & PNG_STRIP_ALPHA)
       png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
-         PNG_FLAG_FILLER_AFTER);
+         PNG_FLAG_FILLER_AFTER,png_ptr->transformations);
 #endif
 
 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
--- libpng-1.2.7.orig/pngtrans.c     2004-09-12 11:19:31.000000000 +0900
+++ libpng-1.2.7/pngtrans.c        2004-11-13 13:04:50.000000000 +0900
@@ -380,7 +380,8 @@
     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
 /* remove filler or alpha byte(s) */
 void /* PRIVATE */
-png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
+png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags,
+  png_uint_32 transformations)
 {
    png_debug(1, "in png_do_strip_filler\n");
 #if defined(PNG_USELESS_TESTS_SUPPORTED)
@@ -392,7 +393,9 @@
       png_uint_32 row_width=row_info->width;
       png_uint_32 i;
 
-      if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
+      if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
+         (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
+         (transformations & PNG_STRIP_ALPHA))) &&
          row_info->channels == 4)
       {
          if (row_info->bit_depth == 8)
@@ -471,7 +474,9 @@
          }
          row_info->channels = 3;
       }
-      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY &&
+      else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
+         (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
+         (transformations & PNG_STRIP_ALPHA))) &&
           row_info->channels == 2)
       {
          if (row_info->bit_depth == 8)
@@ -525,6 +530,8 @@
          }
          row_info->channels = 1;
       }
+      if (transformations & PNG_STRIP_ALPHA)
+        row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
    }
 }
 #endif
--- libpng-1.2.7.orig/pngwtran.c     2004-09-12 11:19:32.000000000 +0900
+++ libpng-1.2.7/pngwtran.c        2004-11-13 13:04:50.000000000 +0900
@@ -40,7 +40,7 @@
 #if defined(PNG_WRITE_FILLER_SUPPORTED)
    if (png_ptr->transformations & PNG_FILLER)
       png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
-         png_ptr->flags);
+         png_ptr->flags,png_ptr->transformations);
 #endif
 #if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
    if (png_ptr->transformations & PNG_PACKSWAP)