Sujet : Re: is there an image package that doesn't require Tk ?
De : avl (at) *nospam* logic.at (Andreas Leitgeb)
Groupes : comp.lang.tclDate : 30. Jun 2024, 17:58:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnv833ko.3gvbf.avl@logic.at>
References : 1 2
User-Agent : slrn/1.0.3 (Linux)
Andreas Leitgeb <
avl@logic.at> wrote:
Andreas Leitgeb <avl@logic.at> wrote:
I'd like it to open a .png file (screenshot from an android
phone) extract five rectangular regions from it, and convert
them to something similar to Tk's [$image data] - e.g. a list
of lists of colors
Thanks to all who answered...
Unfortunately, I haven't yet succeeded with any of the suggestions.
I didn't mean to make anyone "responsible" in any way for a suggestion
made - quite the opposite: I was happy for all suggestions.
In the end I went without tcl package, and merely invoke the
imagemagick tool "convert" with a list of parameters such that
it writes out an uncompressed bmp3 in 16-colors (palette) mode,
which turned out pretty simple to parse from Tcl code (binary scan).
Given a "list-of-list-of-color", it is amazingly simple
to extract a sub-rectangle:
proc rect {data x1 y1 x2 y2} {
lmap row [lrange $data $y1 $y2] { lrange $row $x1 $x2 }
}
Case closed ;-)