in reply to Re: Accessing the pen values of the pixels of a GIF?
in thread Accessing the pen values of the pixels of a GIF?

Finally, a graphics system that lets you at the values in the GIF, rather than pretranslating them back to colours. Thanks for pointing me in the right direction. However, I thought it better to go with this:
#! perl -slw use strict; use GD; my $img = GD::Image->new( $ARGV[0] ) or die $!; my %palette; my $total= 0; my( $x, $y ) = $img->getBounds; for my $yi ( 0 .. $y-1 ) { ++$palette{ $img->getPixel( $_, $yi ) } for 0 .. $x-1; } for my $i ( sort{ $a <=> $b } keys %palette ) { $total += $palette{ $i }; printf "index:%3d (%02x:%02x:%02x) n:%d\n", $i, $img->rgb( $i ), $palette{ $i }; } print( " $x * $y = ", $x*$y, " =?= $total\n");

M.

Replies are listed 'Best First'.
Re^3: Accessing the pen values of the pixels of a GIF?
by BrowserUk (Patriarch) on Nov 08, 2010 at 09:13 UTC

    Good catch on my bounds error. ++