If you read up on Bitmap Structs, you can read in and parse any MCSF Bitmaps (through Version 5). From there, try writing your own bitmaps with pack and syswrite oruse strict; use Fcntl; my %headers = ( 0 => "file-type", 1 => "file-size-in-bytes", 2 => "must-be-0", 3 => "must-be-0", 4 => "offset-to-raster-in-bytes", 5 => "size-of-following-header-in-bytes", 6 => "width-in-pixels", 7 => "height-in-pixels", 8 => "device-planes", 9 => "bits-per-pixel", 10 => "type-of-compression", 11 => "raster-size-in-bytes", 12 => "horizontal-pixels-per-meter", 13 => "vertical-pixels-per-meter", 14 => "number-of-colors-used", 15 => "number-of-important-colors", ); my $x = binary_contents("path/to/bitmap.bmp"); my @x = bmp_headers($x); for my $i(0..$#x){ printf "%-5s %-10s %-20s\n",$i,$x[$i],$headers{$i} } sub bmp_headers { # careful - 's' is endian sensitive my $t = 'a2Vn2V4s2V6'; my $x = shift; unpack($t,$x); } sub binary_contents { my $g = shift; sysopen(my $F, $g, O_RDONLY) or die "cant open: $g\n$!\n"; sysread($F, my $x, -s($g)); close $F; return $x; }
If you want a real challenge, try implementing your own graphics processing algorithms, like applying filters, contrasting, histogram normalization, etc... Try making it As Fast As C. (You can get very, very, close in Pure Perl).open(my $FH, '>:raw', 'path/to/my/new/cool/bitmap.bmp'); print $FH $my_carefully_packed_binary_data
In reply to On Challenging Ways to Learn Perl by mobiusinversion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |