]> git.imager.perl.org - imager.git/commitdiff
zero unfilled channels in color returned by getpixel()
authorTony Cook <tony@develop-help.com>
Fri, 30 Jan 2015 22:57:24 +0000 (09:57 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 30 Jan 2015 22:57:24 +0000 (09:57 +1100)
Imager.xs
t/100-base/010-introvert.t

index 5fe6b4dceab387b5075172a740f7a39c1620fdcd..99e41738cc200e119603dab328a3ee3cdb3b7425 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -3100,6 +3100,7 @@ i_get_pixel(im, x, y)
        i_img_dim y;
       CODE:
        RETVAL = (i_color *)mymalloc(sizeof(i_color));
+       memset(RETVAL, 0, sizeof(*RETVAL));
        if (i_gpix(im, x, y, RETVAL) != 0) {
           myfree(RETVAL);
          XSRETURN_UNDEF;
@@ -3693,6 +3694,7 @@ i_gpixf(im, x, y)
        i_img_dim y;
       CODE:
        RETVAL = (i_fcolor *)mymalloc(sizeof(i_fcolor));
+       memset(RETVAL, 0, sizeof(*RETVAL));
        if (i_gpixf(im, x, y, RETVAL) != 0) {
           myfree(RETVAL);
           XSRETURN_UNDEF;
index e13d57b646f58c8c6bcb463285e02b9efe2be24c..8e46f58f953c5c8a05cccf765a69cc34f1b0c82c 100644 (file)
@@ -934,11 +934,11 @@ my $psamp_outside_error = "Image position outside of image";
   }
 
   # simple calls
-  is_color3($im->getpixel(x => 1, y => 0), 255, 0, 0,
+  is_color4($im->getpixel(x => 1, y => 0), 255, 0, 0, 0,
            "getpixel(1, 0)");
-  is_color3($im->getpixel(x => 8, y => 1), 0, 255, 255,
+  is_color4($im->getpixel(x => 8, y => 1), 0, 255, 255, 0,
            "getpixel(8, 1)");
-  is_color3($im->getpixel(x => 8, y => 7), 255, 0, 255,
+  is_color4($im->getpixel(x => 8, y => 7), 255, 0, 255, 0,
            "getpixel(8, 7)");
 
   {
@@ -970,10 +970,10 @@ my $psamp_outside_error = "Image position outside of image";
   { # float
     is_fcolor3($im->getpixel(x => 1, y => 0, type => 'float'),
               1.0, 0, 0, "getpixel(1,0) float");
-    is_fcolor3($im->getpixel(x => 8, y => 1, type => 'float'),
-              0, 1.0, 1.0, "getpixel(8,1) float");
-    is_fcolor3($im->getpixel(x => 8, y => 7, type => 'float'),
-              1.0, 0, 1.0, "getpixel(8,7) float");
+    is_fcolor4($im->getpixel(x => 8, y => 1, type => 'float'),
+              0, 1.0, 1.0, 0, "getpixel(8,1) float");
+    is_fcolor4($im->getpixel(x => 8, y => 7, type => 'float'),
+              1.0, 0, 1.0, 0, "getpixel(8,7) float");
 
     my @colors = $im->getpixel(x => [ 0, 8, 7 ], y => [ 0, 7, 3 ], type => 'float');
     is(@colors, 3, "getpixel 2 3 element array refs (float)");