Fixed png stripping alpha of all images. Minor changes to png test.
authorArnar Mar Hrafnkelsson <addi@cpan.org>
Wed, 9 May 2001 05:15:05 +0000 (05:15 +0000)
committerArnar Mar Hrafnkelsson <addi@cpan.org>
Wed, 9 May 2001 05:15:05 +0000 (05:15 +0000)
png.c
t/t102png.t

diff --git a/png.c b/png.c
index 70bec0081c308cb5b2cb90dbc62cd691bae252ed..1c0a6ab1fa4d6731bd7674c6db593065426dd2ab 100644 (file)
--- a/png.c
+++ b/png.c
@@ -227,10 +227,9 @@ i_readpng(int fd) {
   /* Strip alpha bytes from the input data without combining with the
    * background (not recommended).
    */
-  if (color_type != PNG_COLOR_TYPE_RGB_ALPHA || color_type != PNG_COLOR_TYPE_GRAY_ALPHA) 
+  if ( (color_type != PNG_COLOR_TYPE_RGB_ALPHA) && (color_type != PNG_COLOR_TYPE_GRAY_ALPHA) )
     png_set_strip_alpha(png_ptr);
 
-
   number_passes = png_set_interlace_handling(png_ptr);
 
   mm_log((1,"number of passes=%d\n",number_passes));
index f868b84711123e8d4bd3e9d26689d01684d2bafd..c1b989aaa00f2b78e499e88076004d3e1ea2f613 100644 (file)
@@ -14,20 +14,20 @@ use Imager qw(:all);
 $loaded = 1;
 print "ok 1\n";
 
-init_log("testout/t10formats.log",1);
+init_log("testout/t102png.log",1);
 
 i_has_format("png") && print "# has png\n";
 
-$green=i_color_new(0,255,0,255);
-$blue=i_color_new(0,0,255,255);
-$red=i_color_new(255,0,0,255);
+$green  = i_color_new(0,   255, 0,   255);
+$blue   = i_color_new(0,   0,   255, 255);
+$red    = i_color_new(255, 0,   0,   255);
 
-$img=Imager::ImgRaw::new(150,150,3);
-$cmpimg=Imager::ImgRaw::new(150,150,3);
+$img    = Imager::ImgRaw::new(150, 150, 3);
+$cmpimg = Imager::ImgRaw::new(150, 150, 3);
 
-i_box_filled($img,70,25,130,125,$green);
-i_box_filled($img,20,25,80,125,$blue);
-i_arc($img,75,75,30,0,361,$red);
+i_box_filled($img, 70, 25, 130, 125, $green);
+i_box_filled($img, 20, 25, 80,  125, $blue);
+i_arc($img, 75, 75, 30, 0, 361, $red);
 i_conv($img,[0.1, 0.2, 0.4, 0.2, 0.1]);
 
 my $timg = Imager::ImgRaw::new(20, 20, 4);
@@ -55,10 +55,10 @@ if (!i_has_format("png")) {
 
   print "ok 3\n";
   print "# png average mean square pixel difference: ",sqrt(i_img_diff($img,$cmpimg))/150*150,"\n";
-  print i_img_diff($img, $cmpimg) 
-       ? "not ok 4 # saved image different\n" : "ok 4\n";
+  print i_img_diff($img, $cmpimg)
+    ? "not ok 4 # saved image different\n" : "ok 4\n";
 
-  open FH, "> testout/t12_trans.png" 
+  open FH, "> testout/t12_trans.png"
     or die "Cannot open testout/t12_trans.png: $!";
   binmode FH;
   if (i_writepng($timg, fileno(FH))) {
@@ -77,6 +77,6 @@ if (!i_has_format("png")) {
 
   print "ok 6\n";
   print "# png average mean square pixel difference: ",sqrt(i_img_diff($timg,$cmpimg))/150*150,"\n";
-  print i_img_diff($timg, $cmpimg) 
+  print i_img_diff($timg, $cmpimg)
        ? "not ok 7 # saved image different\n" : "ok 7\n";
 }