Skip Menu |
 

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 75190
Status: rejected
Priority: 0/
Queue: Imager

People
Owner: Nobody in particular
Requestors: cc [...] nevernet.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: RAW reader does not properly process 4-channel data
Download (untitled) / with headers
text/plain 759b
When reading a raw data string into a 32-bit (4-channel) Imager image, the channels do not seem to end up being aligned properly. It looks like an extra 0 is being injected each time as the alpha byte, and then the next data byte (alpha) is pushed over to be read as the next red byte, and so on, misaligning all data. I have attached a short script showing this behavior. Perl version: This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi OS: Linux 2.6.32-25-generic-pae #45-Ubuntu SMP Sat Oct 16 21:01:33 UTC 2010 i686 GNU/Linux Example output below --> Imager Version: 0.87 Image Dimensions: 2x2, 4 channels. Raw Data: 11 12 13 201 21 22 23 202 31 32 33 203 41 42 43 204 Imager Pixels: 11 12 13 0 201 21 22 0 23 202 31 0 32 33 203 0
Subject: imagertest.pl
Download imagertest.pl
text/x-perl 1k
#!/usr/bin/perl use Imager; ## Set up raw data for a 2x2 4-channel image my $w = 2; my $h = 2; my $numc = 4; my @rawpixels = ( 11,12,13,201, 21,22,23,202, 31,32,33,203, 41,42,43,204 ); my $rawdata = pack('C*', @rawpixels); print "Imager Version: $Imager::VERSION\nImage Dimensions: ${w}x${h}, $numc channels.\n\n"; ## Verify raw data string print "Raw Data:\n"; foreach my $y (0..$h-1) { foreach my $x (0..$w-1) { foreach my $c (0..$numc-1) { my $n = ($y*$h + $x)*$numc + $c; print ord(substr($rawdata,$n,1))." "; } print "\n"; } } print "\n"; ## Read raw data into Imager image my $img = Imager->new(); $img->read( type => 'raw', data => $rawdata, xsize => $w, ysize => $h, channels => 4, storechannels => 4, interleave => 0, ); ## Check Imager resulting pixels print "Imager Pixels:\n"; foreach my $y (0..$h-1) { foreach my $x (0..$w-1) { my $color = $img->getpixel(x=>$x, y=>$y); print join(' ', $color->rgba())."\n"; } } print "\n"; exit(0);
Subject: Re: [rt.cpan.org #75190] RAW reader does not properly process 4-channel data
Date: Wed, 22 Feb 2012 00:01:46 +1100
To: "http://ccjuju.myopenid.com/ via RT" <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
Download (untitled) / with headers
text/plain 731b
On Tue, Feb 21, 2012 at 07:06:08AM -0500, http://ccjuju.myopenid.com/ via RT wrote: Show quoted text
> When reading a raw data string into a 32-bit (4-channel) Imager image, > the channels do not seem to end up being aligned properly. It looks > like an extra 0 is being injected each time as the alpha byte, and then > the next data byte (alpha) is pushed over to be read as the next red > byte, and so on, misaligning all data. I have attached a short script > showing this behavior. >
Please try setting datachannels to 4: $img->read( type => 'raw', data => $rawdata, xsize => $w, ysize => $h, datachannels => 4, # this was channels => 4 storechannels => 4, interleave => 0, ); Tony
Download (untitled) / with headers
text/plain 135b
On Tue Feb 21 08:02:02 2012, tony@develop-help.com wrote: Show quoted text
> Please try setting datachannels to 4:
That seems to do the trick, thanks!


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.