Shortly thereafter I started learning perl, and decide to revisit this idea because it sounded like a somewhat easy task in perl. I decided that the best place to get data would be from and BMP file because of the lack of compression. After about ten minutes of coding I produced this very useless script that takes an ordinary windows BMP file and converts it into a HTML document.
Beware running this script as it has almost no use. Also note that the output of a 400 by 400 BMP could be larger than 10MB. I havn't done extensive testing with this script either. I have only been using 24-bit BMP files created by windows paint.#!/usr/bin/perl -w use strict; my $bmp = "pic.bmp"; my $html = "pic.html"; my $temp; open (IN, "<$bmp") || die; while(<IN>) { $temp .= $_; } close IN; my $col = (ord(substr $temp,18,1)) + (256*(ord(substr $temp,19,1))); my $row = (ord(substr $temp,22,1)) + (256*(ord(substr $temp,23,1))); my $numread = $col * 3; while ( ($numread % 4) != 0 ) { $numread++; } open (OUT, ">$html") || die; print OUT "<html><head></head><body><table border='0' cellpadding='0' +cellspacing='0'>"; for (my $i = ($row-1); $i >= 0; $i--) { print OUT "<tr>"; for my $j (0..($col-1)) { print OUT "<td height='1' width='1' bgcolor='#"; for (my $x = 2; $x >= 0; $x--) { my $temp1 = ord(substr($temp,54+$i*$numread+$j*3+$x,3)); print OUT sprintf "%02x",$temp1; } print OUT "'></td>"; } print OUT "</tr>"; } print OUT "</table></body></html>"; close OUT;
UPDATED: Added some info on what BMP files I had been using.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Table Pictures
by John M. Dlugosz (Monsignor) on Jun 11, 2001 at 22:18 UTC | |
|
Re: Table Pictures
by mr_mischief (Monsignor) on Jun 12, 2001 at 05:18 UTC | |
|
Re: Table Pictures
by naChoZ (Curate) on Jun 12, 2001 at 05:42 UTC | |
|
Something very similar...
by gaudior (Pilgrim) on Jun 12, 2001 at 20:08 UTC |