- my $out = Imager->new(xsize => 10, ysize => 10, channels => 4);
- $out->box(fill => $fill50);
- is_color4($out->getpixel(x => 0, y => 0),
- 255, 0, 0, 16, "check alpha output");
- is_color4($out->getpixel(x => 2, y => 1),
- 0, 255, 0, 64, "check alpha output");
- $out->box(filled => 1, color => "000000");
- is_color4($out->getpixel(x => 0, y => 0),
- 0, 0, 0, 255, "check after clear");
- $out->box(fill => $fill50);
- is_color4($out->getpixel(x => 4, y => 2),
- 16, 0, 0, 255, "check drawn against background");
- is_color4($out->getpixel(x => 6, y => 3),
- 0, 64, 0, 255, "check drawn against background");
+
+ { # 4 channel image
+ my $out = Imager->new(xsize => 10, ysize => 10, channels => 4);
+ $out->box(fill => $fill50);
+ is_color4($out->getpixel(x => 0, y => 0),
+ 255, 0, 0, 16, "check alpha output");
+ is_color4($out->getpixel(x => 2, y => 1),
+ 0, 255, 0, 64, "check alpha output");
+ $out->box(filled => 1, color => "000000");
+ is_color4($out->getpixel(x => 0, y => 0),
+ 0, 0, 0, 255, "check after clear");
+ $out->box(fill => $fill50);
+ is_color4($out->getpixel(x => 4, y => 2),
+ 16, 0, 0, 255, "check drawn against background");
+ is_color4($out->getpixel(x => 6, y => 3),
+ 0, 64, 0, 255, "check drawn against background");
+ }
+ { # 3 channel image
+ my $out = Imager->new(xsize => 10, ysize => 10, channels => 3);
+ $out->box(fill => $fill50);
+ is_color3($out->getpixel(x => 0, y => 0),
+ 16, 0, 0, "check alpha output");
+ is_color3($out->getpixel(x => 2, y => 1),
+ 0, 64, 0, "check alpha output");
+ is_color3($out->getpixel(x => 0, y => 1),
+ 128, 128, 0, "check alpha output");
+ }