Put your image up in the air

My goal is to use an image and output it to the marquee. I really don’t want to build matrix characters one by one. I mostly want to create anti-aliased characters or graphics. How? By making the leds blink more or less time. That will make the glow-in-the-dark stripe illuminate more when the led lit more longer. So, for now, I code a test program in PHP, a familiar language for me, to read the image and output the result data I need to give to the Arduino microcontroler.

There is the idea of code :

<?php
/*
	This script display a black and white graphic
	constructed in a html table
	based on the readed jpg image.

*/
// Declare the image file to read.
$file = "test.jpg";
// Read the jpg file and create an image in memory.
$image = imagecreatefromjpeg($file);
// Get the size of the image.
$width = imagesx($image);
$height = imagesy($image);

print "<table><tr>";
// Read one row of the image at a time.
for ($y=0; $y < $height; $y++) {
	// Read one column of the image at a time.
	for ($x=0; $x < $width; $x++) {
		// Get the index of a pixel.
		$pix_index = imagecolorat($image,$x,$y);
		// Get the decimal RGB color of this pixel.
		$A = imagecolorsforindex($image,$pix_index);
		// Convert this color to gray scale.
		$col = ($A['red'] + $A['green'] + $A['blue'] ) / 3;
		// Convert this color to hex.
		$col = dechex($col);
		
		print "<td style=\"width:10px;height:10px;background-color:#{$col}{$col}{$col}\">&nbsp;</td>";
	}
	print"</tr><tr>";
}
print "</tr></table>";
?>

Leave a Reply

Your email address will not be published. Required fields are marked *