Skip to content

Instantly share code, notes, and snippets.

@larsen
Created June 7, 2011 15:40
Show Gist options
  • Save larsen/1012512 to your computer and use it in GitHub Desktop.
Save larsen/1012512 to your computer and use it in GitHub Desktop.
my $strlenght = 88 ;
my $i = 0 ;
OUTER: for (my $w = 0 ; $w < $img->width ; $w++ ) {
for (my $h = 0 ; $h < $img->height ; $h++ ) {
my ($r, $g, $b) = $img->rgb($img->getPixel($w, $h)) ;
last OUTER if ($i eq $strlength);
my $rbit = $r & 0x01 ;
my $gbit = $g & 0x01 ;
my $bbit = $b & 0x01 ;
push @bits, $rbit ; $i++ ;
push @bits, $gbit ; $i++ ;
push @bits, $bbit ; $i++ ;
}
last if ($i eq $strlength) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment