If you would like a nice way to visualize it, and have mouse interaction, look at this gtk2 example by Dov Grobgeld. It could be adapted to line-by-line output.
#!/usr/bin/perl ###################################################################### # An example of how to get rgb value in a motion callback of # the image shown in Gtk2::Image. # # Dov Grobgeld <dov.grobgeld@gmail.com> # 2005-08-28 # # This code is in the public domain. ###################################################################### use strict; use Gtk2 '-init'; sub get_rgb { my($img, $x,$y) = @_; return unpack("C3", $img->new_subpixbuf($x,$y,1,1)->get_pixels()); } sub cb_image_motion { my ($this, $event, $user_data) = @_; my ($label, $pb) = @$user_data; my $x = $event->x; my $y = $event->y; my $info = sprintf("Coord: (%3d,%3d) rgb: (%3d,%3d,%3d)",$x,$y, get_rgb($pb, $x,$y)); $label->set(label=>$info); return 1; } sub create_widgets { my $filename = shift || 'bridget-1.jpg'; my $mw = Gtk2::Window->new(); $mw->signal_connect (delete_event => sub {Gtk2->main_quit;}); # create a vbox for the image and a label my $vbox = Gtk2::VBox->new(); $mw->add($vbox); # Create an eventbox and put the image inside it my $event_box = Gtk2::EventBox->new(); my $image = Gtk2::Image->new(); $vbox->pack_start($event_box, 1,1,0); $event_box->add($image); # Load an image into a pixbuf. This gives more flexibility in # manipulating the image than using an Gdk::Pixmap. my $pb = new_from_file Gtk2::Gdk::Pixbuf($filename); die "Failed loading test image!\n" unless $pb; # create info label my $label = Gtk2::Label->new($filename); $vbox->pack_start($label, 0,0,0); # Load the image into the image widget and resize it so that # it fits the image $image->set_from_pixbuf($pb); $image->set_size_request($pb->get_width, $pb->get_height); # Make event box accept motion events $event_box->set_events(["pointer-motion-mask"]); # setup motion callback for the image widget $event_box->signal_connect( "motion-notify-event"=>\&cb_image_motion,[$label,$pb]); $mw->show_all(); } create_widgets(@ARGV); Gtk2->main();

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: A way to read in bitmaps pixel by pixel? by zentara
in thread A way to read in bitmaps pixel by pixel? by dark314

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.