Skip Menu |
 

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 71309
Status: resolved
Priority: 40/
Queue: Imager

People
Owner: Nobody in particular
Requestors: Ralf.Neubauer [...] wido.bv.aok.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.85
Fixed in: 0.86



From Ralf.Neubauer [...] wido.bv.aok.de Wed Sep 28 09: 52:59 2011
X-Originalarrivaltime: 28 Sep 2011 13:52:24.0090 (UTC) FILETIME=[D9BC97A0:01CC7DE5]
MIME-Version: 1.0
X-Spam-Status: No, score=-6.899 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_FAIL=0.001] autolearn=ham
Content-Class: urn:content-classes:message
X-Spam-Flag: NO
Message-ID: <DA5D2621C9566F488C32ACE506A7BB89019F5BC9 [...] wido-exch01.wido.bv.aok.de>
content-type: text/plain; charset="utf-8"
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-MS-Tnef-Correlator:
X-Ironport-Anti-Spam-Tag: nospam
X-Ironport-Av: E=Sophos;i="4.68,455,1312149600"; d="scan'208";a="169528182"
X-Spam-Score: -6.899
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B31EC240A2F for <cpan-bug+Imager [...] hipster.bestpractical.com>; Wed, 28 Sep 2011 09:52:59 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JCGY2euvVLz7 for <cpan-bug+Imager [...] hipster.bestpractical.com>; Wed, 28 Sep 2011 09:52:57 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id A7393240902 for <bug-Imager [...] rt.cpan.org>; Wed, 28 Sep 2011 09:52:57 -0400 (EDT)
Received: (qmail 3191 invoked by uid 103); 28 Sep 2011 13:52:56 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Sep 2011 13:52:56 -0000
Received: from mailext.aok.de (HELO mailext.aok.de) (217.111.83.65) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Wed, 28 Sep 2011 06:52:52 -0700
Received: from gfgv-aok-li37-fromint.zsa.aok.de (HELO gfgv-aok-li37.localdomain) ([10.160.41.219]) by mailint3.zsa.aok.de with ESMTP; 28 Sep 2011 15:52:24 +0200
Received: from gfgv-aok-li37 (localhost.localdomain [127.0.0.1]) by gfgv-aok-li37.localdomain (Postfix) with ESMTP id 63EC1651717 for <bug-Imager [...] rt.cpan.org>; Wed, 28 Sep 2011 15:52:24 +0200 (CEST)
Received: from mailext.aok.de (gfgv-aok-ip01ext.zsa.aok.de [10.160.41.206]) by gfgv-aok-li37.localdomain (Postfix) with ESMTP id 5ABBD6516EF for <bug-Imager [...] rt.cpan.org>; Wed, 28 Sep 2011 15:52:24 +0200 (CEST)
Received: from gfgv-aok-ip11.zsa.aok.de (HELO mailhub1.zsa.aok.de) ([10.160.36.3]) by mailint3.zsa.aok.de with ESMTP; 28 Sep 2011 15:52:24 +0200
Received: from unknown (HELO exch02.bv.aok.de) ([10.116.0.21]) by mailhub1.zsa.aok.de with ESMTP; 28 Sep 2011 15:52:24 +0200
Received: from wido-exch01.wido.bv.aok.de ([10.116.2.3]) by exch02.bv.aok.de with Microsoft SMTPSVC(6.0.3790.4675); Wed, 28 Sep 2011 15:52:24 +0200
Delivered-To: cpan-bug+Imager [...] hipster.bestpractical.com
Subject: polygons don't fit
Return-Path: <Ralf.Neubauer [...] wido.bv.aok.de>
Thread-Index: Acx95djaU1QTyBEkRtKWpNERRGriZQ==
X-RT-Mail-Extension: imager
X-Original-To: cpan-bug+Imager [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Wed, 28 Sep 2011 15:52:23 +0200
X-Spam-Level:
Thread-Topic: polygons don't fit
X-MS-Has-Attach:
X-Mimeole: Produced By Microsoft Exchange V6.5
To: <bug-Imager [...] rt.cpan.org>
Content-Transfer-Encoding: quoted-printable
X-Ironport-Faked-Sender: false
X-Ironport-Faked-Sender: false
From: "Neubauer, Ralf" <Ralf.Neubauer [...] wido.bv.aok.de>
X-RT-Original-Encoding: us-ascii
Content-Length: 3014
Download (untitled) / with headers
text/plain 2.9k
Hi. Distribution name and version: Imager-0.85 Perl version: v5.12.4 -- Binary build 1205 [294981] provided by ActiveState Operating System vendor and version: WinXP After building the very useful Imager module myself (because the ActiveState PPMs are buggy and e.g. don't support PNG and JPEG) I still get an effect that I first discovered some years ago with older (ActiveState and trouchelle distributed) Versions of Imager and perl: #! /usr/bin/perl use warnings; use strict; use Imager; my $img = new Imager(xsize => 100, ysize => 100, channels => 1); my $white = Imager::Color->new(255, 255, 255); my $black = Imager::Color->new(0, 0, 0); $img->box(color => $white, filled => 1, xmin => 0, ymin => 0, xmax => 99, ymax => 99); $img->polygon(color => $black, points => [[0,0], [0,99], [99,99]]); $img->polygon(color => $black, points => [[0,0], [99,99], [99,0]]); $img->write(file => 'polygonmatch.bmp') There is a fine grey line from (0,0) to (99,99). If I draw a shaded triangulation, e.g. 3D shaded boxes, I don't get a nice shaded image, but there are these lines between the triangles. Example: use Imager::Fountain; use Imager::Fill; my $cells = 10; my $xcell = 100; my $ycell = 150; $img = new Imager(xsize => $xcell*$cells, ysize => $ycell*$cells, channels => 3); my @color = map Imager::Color->new(map int rand 256, 0..2), 0..2; my $fountain = Imager::Fountain->simple (positions => [0, 0.1, 0.3, 0.7, 0.9, 1.0], colors => [@color[0, 1, 2, 2, 3, 0]]); for my $x (0..99) { for my $y (0..99) { my $tl = [$xcell*$x, $ycell*$y]; my $tr = [$xcell*$x+$xcell-1, $ycell*$y]; my $bl = [$xcell*$x, $ycell*$y+$ycell-1]; my $br = [$xcell*$x+$xcell-1, $ycell*$y+$ycell-1]; my $center = [$xcell*$x+int(($xcell-1)/2), $ycell*$y+int(($ycell-1)/2)]; my $fill_top_bottom = Imager::Fill->new(fountain => 'linear', segments => $fountain, xa => $tl->[0], ya => $tl->[1], xb => $bl->[0], yb => $bl->[1], ); my $fill_left_right = Imager::Fill->new(fountain => 'linear', segments => $fountain, xa => $tl->[0], ya => $tl->[1], xb => $tr->[0], yb => $tr->[1], ); $img->polygon(fill => $fill_top_bottom, points => [$br, $center, $bl]); $img->polygon(fill => $fill_top_bottom, points => [$tl, $center, $tr]); $img->polygon(fill => $fill_left_right, points => [$bl, $center, $tl]); $img->polygon(fill => $fill_left_right, points => [$tr, $center, $br]); } } $img->write(file => 'polygonmatch2.bmp'); The easiest fix would be an option for non-antialiased polygons. I tried hiding the artefacts behind lines: for my $xincr (-1,0,1) { $img->line(color => $color, aa => 0, x1 => $bl->[0]+$xincr, y1 => $bl->[1], x2 => $tr->[0]+$xincr, y2 => $tr->[1]); $img->line(color => $color, aa => 0, x1 => $br->[0]+$xincr, y1 => $br->[1], x2 => $tl->[0]+$xincr, y2 => $tl->[1]); } but that doesn't catch all pixels -- and is still the wrong color anyways. Ralf
MIME-Version: 1.0
In-Reply-To: <DA5D2621C9566F488C32ACE506A7BB89019F5BC9 [...] wido-exch01.wido.bv.aok.de>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <DA5D2621C9566F488C32ACE506A7BB89019F5BC9 [...] wido-exch01.wido.bv.aok.de>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-3052-1317293397-1304.71309-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2252
Download (untitled) / with headers
text/plain 2.1k
On Wed Sep 28 09:53:00 2011, Ralf.Neubauer@wido.bv.aok.de wrote: Show quoted text
> After building the very useful Imager module myself (because the > ActiveState PPMs are buggy and e.g. don't support PNG and JPEG) I still > get an effect that I first discovered some years ago with older > (ActiveState and trouchelle distributed) Versions of Imager and perl: >
... Show quoted text
> There is a fine grey line from (0,0) to (99,99). If I draw a shaded > triangulation, e.g. 3D shaded boxes, I don't get a nice shaded image, > but there are these lines between the triangles. Example:
From looking at your code and the results I think you're encoutering two different problems: a) for your first sample, you're encountering a limitation in anti-aliasing, where two different operations have 50% coverage on the same pixels, producing 75% coverage instead of the mathematically expected coverage of 100%. As you say this could be fixed if Imager provided a non-AA polygon function. b) your second sample illustrates what seems to be a real bug in drawing anti-aliased polygons, and I've tracked it down. As a workaround for b) supply a combine of "normal" when creating the fill: my $fill_top_bottom = Imager::Fill->new(fountain => 'linear', segments => $fountain, xa => $tl->[0], ya => $tl->[1], xb => $bl->[0], yb => $bl->[1], combine => "normal", ); my $fill_left_right = Imager::Fill->new(fountain => 'linear', segments => $fountain, xa => $tl->[0], ya => $tl->[1], xb => $tr->[0], yb => $tr->[1], combine => "normal", ); To avoid a) for your tiles, you can fill the entire box with your top to bottom fill, then fill in the sides with the side fills: $img->polygon(fill => $fill_top_bottom,points => [$br, $tr, $tl, $bl]); $img->polygon(fill => $fill_left_right, points => [$bl, $center,$tl]); $img->polygon(fill => $fill_left_right, points => [$tr, $center,$br]); Your code does have a couple of small bugs: 1) when you initialize $fountain, you reference @color index 3, which you haven't initialized. 2) you fill 100 tiles in each dimension, while you only have 10. I'll look at a fix for b) for the next release of Imager. The anti-aliased polygons will need to wait a bit longer. Tony
MIME-Version: 1.0
In-Reply-To: <DA5D2621C9566F488C32ACE506A7BB89019F5BC9 [...] wido-exch01.wido.bv.aok.de>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <DA5D2621C9566F488C32ACE506A7BB89019F5BC9 [...] wido-exch01.wido.bv.aok.de>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2603-1320097259-255.71309-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 963
Download (untitled) / with headers
text/plain 963b
On Wed Sep 28 09:53:00 2011, Ralf.Neubauer@wido.bv.aok.de wrote: Show quoted text
> > After building the very useful Imager module myself (because the > ActiveState PPMs are buggy and e.g. don't support PNG and JPEG) I still > get an effect that I first discovered some years ago with older > (ActiveState and trouchelle distributed) Versions of Imager and perl:
... Show quoted text
> > The easiest fix would be an option for non-antialiased polygons. > > I tried hiding the artefacts behind lines: > > for my $xincr (-1,0,1) { > $img->line(color => $color, aa => 0, > x1 => $bl->[0]+$xincr, y1 => $bl->[1], > x2 => $tr->[0]+$xincr, y2 => $tr->[1]); > $img->line(color => $color, aa => 0, > x1 => $br->[0]+$xincr, y1 => $br->[1], > x2 => $tl->[0]+$xincr, y2 => $tl->[1]); > } > > but that doesn't catch all pixels -- and is still the wrong color > anyways.
I've fixed the black border bug described here for Imager 0.86. Thanks, Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.