Reading Pixels From Stdin

I made a quick little tcl/tk script to read pixels from stdin, and then display them on the screen. You run it like this:

wish streaming_pixels.tk <width> <height> <pixels-per-repaint> <magnification>

Then you send lines of the form "x y r g b" into stdin. For example, here's a perl script that generates an animation of a 20x20 grid of pixels with a red/green gradient, with the blue component increasing slowly:

for $z (0..9) {
    for $y (0..19) {
        for $x (0..19) {
            print "$x $y ".($x*13)." ".($y*13)." ".($z*26)."\n";
        }
    }
}

If you pipe this into the streaming_pixels script, with a magnification of 4, you get this:

->
perl genpixels.pl | wish streaming_pixels.tk 20 20 400 4

There are two advantage to this script as opposed to the numerous others that convert text formats into images. First, the pixels don't have to be in strict top-down left-right order -- you can send in pixels for any part of the image at any time. Second, you can overwrite pixel values that have already been input, so the script can handle animations.

I don't know enough tcl to make the script process all the pixels that are available before repainting, so instead you have to explicitly specify how many pixels it should read in between repaints. There's a 100ms wait between repaints, so don't set this number too low or you'll die of old age before it finishes the first frame. I also don't know enough to make it handle end-of-input correctly, so instead you just have to ignore the error message at the end.

Posted on August 9, 2004 06:50 PM
More programming articles

Comments

Though I realize it's just a linear gradient, those really remind me of the old sineplasmas you wrote.

Posted by: Jesse at August 9, 2004 07:47 PM

Yep, I've always been a pushover for high-saturation images produced with minimal code.

That and the color orange :)

Posted by: Kim at August 13, 2004 10:12 AM

If you're interested in this sort of image manipulation you'd do well to take a close look at Pancito:

http://www.acooke.org/jara/pancito/intro.html

Posted by: aaa at August 22, 2004 05:43 AM

Louis Vuitton , commonly referred to as Louis Vuitton Monogram Groom Serials and Louis Vuitton Launching, or sometimes shortened to Louis Vuitton 2010 has become one of the most Marc Jacobs Louis Vuitton Agendas luxurybrands Louis Vuitton Watches.

Posted by: 1 at November 17, 2009 02:01 AM

UGG Bailey Button bootsis a new style in 2009.The classic cardy uggs boots is another hot boots that worth of buying.And the classic tall ugg boots will make your winter amusing.And now uggs on sale,if you are looking for such a boot,the ugg boots is good choice this year.

Posted by: uggs on sale at November 17, 2009 08:28 PM

Uggs on sale now.Classic cardy boots ugg is a special boot that makes you different from the other girls.And the Bailey Button UGGs is hot in 2009.If you want to get a warm shoe in cold winter,I think ugg classic tall boots is a good choice for you.

Posted by: ugg classic cardy boots at November 17, 2009 09:02 PM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 23, 2009 10:15 PM

Good day! Thx for your great post and Im thinking about how to introduce my ugg boots to you cos Im not sure if u like this. Many people who live in the cold area like the ugg boots, especially the north-europe. Our uggshare.co.uk supply the cheapest classic cardy ugg boots, class tall ugg boots, classic short ugg boots and other series of uggs, hope my words didn’t trouble u, cy!

Posted by: ugg boots at November 24, 2009 08:58 PM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 25, 2009 12:20 AM

People all over the world know the abercrombie and fitch,but not everyone really knows how fashion the abercrombie is,hollister is the Legend maker. Everybody wears the hollister clothing would be the abercrombie mens and the abercrombie womens, if you want know you can search the Ruehl No.925 or abercrombie outlet in the www.google.com .

Posted by: fitch at November 25, 2009 10:32 PM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
ugg bailey button
Wow, my ugg classic mini will not be coming off now! I’ve had them on for 12hrs strait and I do not want to take them off. Thanks for everything, well worth the wait.

Posted by: ugg bailey button boots at November 30, 2009 06:25 AM
Post a comment









Remember info?




Prove you're human. Type "human":