Search code examples
perlimagetk-toolkitperltk

perl-tk: Interactivity visualize a large 2d raster data (like xvcg)


I want to write a perl application using tk to visualize a large 2d plot (it can be considered as 2d image). I need scrolling and resizing. Also I need not to store entire image in memory.

It is too big to be saved at one huge picture, but I can easy redraw any part of it. So, I want to write a graphic application to view this data in interactive mode. This is like what xvcg do for graphs: http://blogs.oracle.com/amitsaha/resource/blog-shots/apt-rdepends.png (it is example of interface. There are x and y scroll bars and zoom bars)

My data looks a bit like http://www.access-excel-vba.com/giantchart.png without any text with thinner (1px) lines, a lot of dots on them and have sizes (at now) from 33000x23000 and will be bigger. I use 2bit-per-pixel Images.

So, How can I progamm a scrollable and zoomable image viewer in perl/tk? The requirement is not to store entire image in memory (190 Mb now and will be more!), but ask some function to draw it in parts.

About language/toolkit selection. My data generator is written on perl, OS is unix/POSIX, so I want not to switch language. I able to switch to another graphic toolkit, but perl/tk is preinstalled on target PCs.


Solution

  • Use a Canvas widget. You can place images or draw directly, in which case the built-in scale method would handle resizing. With the right handlers for scrolling you could dynamically load and unload content as you moved around to keep the memory usage reasonable. e.g. the callback for the -xscrollcommand would detect when you scroll right into an unloaded area and load the content for that area. You could unload items once then go off-screen.