I thought only '1' or '.' were acceptable to set or not set the pixels?
pack template 'b', only considers the low bit of each byte, thus all these produce the same results:
print unpack 'b8', pack 'b8', '01010101';;
01010101
print unpack 'b8', pack 'b8', 'babababa';;
01010101
print unpack 'b8', pack 'b8', "\x00\x01\x00\x01\x00\x01\x00\x01";;
01010101
print unpack 'b8', pack 'b8', "()()()()";;
01010101
print unpack 'b8', pack 'b8', "@?@?@?@?";;
01010101
print unpack 'b8', pack 'b8', 'dcdcdcdc';;
01010101
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
.
| [reply] [d/l] |
hello gimcdan,
aside from pack, the mention of pixel let me think you are inspecting a template for an image: my little experience with bitmap was due to my project about Tartaglia's triangle.
As far as i remember in the image you have some header where you declare the size of the bitmap (x and y), the number of colors used and a fourth parameter i dont know..
Then you can declare a map between char and colors. In the example below the space is the background (mapped to black) and the # is mapped to red.This is mentioned in Mastering PerlTk also.
So, if you are talking about bitmap, any char is acceptable to set a pixel because it sets it's color.
sub tart_icon {
return <<EOI
/* XPM */
static char * Icon_xpm[] = {
"32 32 4 1",
" c #000000000000",
"g c #00FF00",
"X c #FF0000",
"D c #FFFF00",
" ",
" ",
" ",
" ",
" ",
" ",
" XXXXXXXXXXXXXXXX ",
" XXXXXXXXXXXXXXXX ",
" ",
" ",
" XX ",
" XX ",
" XXXX ",
" XXXX ",
" XXXXXX ",
" XXXXXX ",
" XXXXXXXX ",
" XXXXXXXX ",
" XXXXXXXXXX ",
" XXXXXXXXXX ",
" XXXXXXXXXXXX ",
" XXXXXXXXXXXX ",
" XXXXXXXXXXXXXX ",
" XXXXXXXXXXXXXX ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",};
EOI
}
HtH L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] |
use Image::Xbm;
my $bits = pack 'b*',
Image::Xbm->new_from_string( $str )->as_binstring ;
| [reply] [d/l] |