summaryrefslogtreecommitdiff
blob: 29b73233610bf909588cf84f8b344d9906809cc9 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
diff -Nuar --exclude '*.orig' --exclude '*.rej' pngtools-0.4.orig//pnginfo.c pngtools-0.4/pnginfo.c
--- pngtools-0.4.orig//pnginfo.c	2011-09-16 07:05:05.235477249 +0000
+++ pngtools-0.4/pnginfo.c	2011-09-16 07:07:52.385872705 +0000
@@ -185,20 +185,25 @@
   ///////////////////////////////////////////////////////////////////////////
 
   printf ("  Image Width: %d Image Length: %d\n", width, height);
+  int pixel_depth;
+  pixel_depth = bitdepth * png_get_channels(png, info);
   if(tiffnames == pnginfo_true){
     printf ("  Bits/Sample: %d\n", bitdepth);
-    printf ("  Samples/Pixel: %d\n", info->channels);
-    printf ("  Pixel Depth: %d\n", info->pixel_depth);	// Does this add value?
+    printf ("  Samples/Pixel: %d\n", png_get_channels(png, info));
+    printf ("  Pixel Depth: %d\n", pixel_depth);	// Does this add value?
   }
   else{
     printf ("  Bitdepth (Bits/Sample): %d\n", bitdepth);
-    printf ("  Channels (Samples/Pixel): %d\n", info->channels);
-    printf ("  Pixel depth (Pixel Depth): %d\n", info->pixel_depth);	// Does this add value?
+    printf ("  Channels (Samples/Pixel): %d\n", png_get_channels(png, info));
+    printf ("  Pixel depth (Pixel Depth): %d\n", pixel_depth);	// Does this add value?
   }
 
   // Photometric interp packs a lot of information
   printf ("  Colour Type (Photometric Interpretation): ");
 
+  int num_palette;
+  int num_trans;
+
   switch (colourtype)
     {
     case PNG_COLOR_TYPE_GRAY:
@@ -207,10 +212,10 @@
 
     case PNG_COLOR_TYPE_PALETTE:
       printf ("PALETTED COLOUR ");
-      if (info->num_trans > 0)
+      if (num_trans > 0)
 	printf ("with alpha ");
       printf ("(%d colours, %d transparent) ",
-	      info->num_palette, info->num_trans);
+	      num_palette, num_trans);
       break;
 
     case PNG_COLOR_TYPE_RGB:
@@ -232,7 +237,7 @@
   printf ("\n");
 
   printf ("  Image filter: ");
-  switch (info->filter_type)
+  switch (png_get_filter_type(png, info))
     {
     case PNG_FILTER_TYPE_BASE:
       printf ("Single row per byte filter ");
@@ -249,7 +254,7 @@
   printf ("\n");
 
   printf ("  Interlacing: ");
-  switch (info->interlace_type)
+  switch (png_get_interlace_type(png, info))
     {
     case PNG_INTERLACE_NONE:
       printf ("No interlacing ");
@@ -266,7 +271,7 @@
   printf ("\n");
 
   printf ("  Compression Scheme: ");
-  switch (info->compression_type)
+  switch (png_get_compression_type(png, info))
     {
     case PNG_COMPRESSION_TYPE_BASE:
       printf ("Deflate method 8, 32k window");
@@ -278,9 +283,13 @@
     }
   printf ("\n");
 
+  png_uint_32 x_pixels_per_unit, y_pixels_per_unit;
+  int phys_unit_type;
+  png_get_pHYs (png, info, &x_pixels_per_unit, &y_pixels_per_unit, &phys_unit_type);
+
   printf ("  Resolution: %d, %d ",
-	  info->x_pixels_per_unit, info->y_pixels_per_unit);
-  switch (info->phys_unit_type)
+	  x_pixels_per_unit, y_pixels_per_unit);
+  switch (phys_unit_type)
     {
     case PNG_RESOLUTION_UNKNOWN:
       printf ("(unit unknown)");
@@ -299,15 +308,18 @@
   // FillOrder is always msb-to-lsb, big endian
   printf ("  FillOrder: msb-to-lsb\n  Byte Order: Network (Big Endian)\n");
 
+  png_textp text;
+  int num_text, max_text;
+
   // Text comments
   printf ("  Number of text strings: %d of %d\n",
-	  info->num_text, info->max_text);
+	  num_text, max_text);
 
-  for (i = 0; i < info->num_text; i++)
+  for (i = 0; i < num_text; i++)
     {
-      printf ("    %s ", info->text[i].key);
+      printf ("    %s ", text[i].key);
 
-      switch (info->text[1].compression)
+      switch (text[1].compression)
 	{
 	case -1:
 	  printf ("(tEXt uncompressed)");
@@ -332,12 +344,12 @@
 
       printf (": ");
       j = 0;
-      while (info->text[i].text[j] != '\0')
+      while (text[i].text[j] != '\0')
 	{
-	  if (info->text[i].text[j] == '\n')
+	  if (text[i].text[j] == '\n')
 	    printf ("\\n");
 	  else
-	    fputc (info->text[i].text[j], stdout);
+	    fputc (text[i].text[j], stdout);
 
 	  j++;
 	}
@@ -385,14 +397,14 @@
 
 	  printf ("Dumping the bitmap for this image:\n");
 	  printf ("(Expanded samples result in %d bytes per pixel, %d channels with %d bytes per channel)\n\n", 
-		  info->channels * bytespersample, info->channels, bytespersample);
+		  png_get_channels(png, info) * bytespersample, png_get_channels(png, info), bytespersample);
 
 	  // runlen is used to stop us displaying repeated byte patterns over and over --
 	  // I display them once, and then tell you how many times it occured in the file.
 	  // This currently only applies to runs on zeros -- I should one day add an
 	  // option to extend this to runs of other values as well
 	  runlen = 0;
-	  for (i = 0; i < rowbytes * height / info->channels; i += info->channels * bytespersample)
+	  for (i = 0; i < rowbytes * height / png_get_channels(png, info); i += png_get_channels(png, info) * bytespersample)
 	    {
 	      int scount, bcount, pixel;
 
@@ -408,16 +420,16 @@
 
 	      // Determine if this is a pixel whose entire value is zero
 	      pixel = 0;
-	      for(scount = 0; scount < info->channels; scount++)
+	      for(scount = 0; scount < png_get_channels(png, info); scount++)
 		for(bcount = 0; bcount < bytespersample; bcount++)
 		  pixel += bitmap[i + scount * bytespersample + bcount];
 
 	      if ((runlen == 0) && !pixel)
 		{
 		  printf ("[");
-		  for(scount = 0; scount < info->channels; scount++){
+		  for(scount = 0; scount < png_get_channels(png, info); scount++){
 		    for(bcount = 0; bcount < bytespersample; bcount++) printf("00");
-		    if(scount != info->channels - 1) printf(" ");
+		    if(scount != png_get_channels(png, info) - 1) printf(" ");
 		  }
 		  printf ("] ");
 		  runlen++;
@@ -425,10 +437,10 @@
 
 	      if (runlen == 0){
 		printf ("[");
-		for(scount = 0; scount < info->channels; scount++){
+		for(scount = 0; scount < png_get_channels(png, info); scount++){
 		  for(bcount = 0; bcount < bytespersample; bcount++)
 		    printf("%02x", (unsigned char) bitmap[i + scount * bytespersample + bcount]);
-		  if(scount != info->channels - 1) printf(" ");
+		  if(scount != png_get_channels(png, info) - 1) printf(" ");
 		}
 		printf("] ");
 	      }
diff -Nuar --exclude '*.orig' --exclude '*.rej' pngtools-0.4.orig//pngread.c pngtools-0.4/pngread.c
--- pngtools-0.4.orig//pngread.c	2011-09-16 07:05:05.235477249 +0000
+++ pngtools-0.4/pngread.c	2011-09-16 07:05:44.865570870 +0000
@@ -68,7 +68,7 @@
   // palette is correctly reported...
   //png_set_strip_alpha (png);
   png_read_update_info (png, info);
-  *channels = info->channels;
+  *channels = png_get_channels(png, info);
   
   rowbytes = png_get_rowbytes (png, info);
   if((row_pointers = malloc (*height * sizeof (png_bytep))) == NULL){