in reply to Tk:Photo -data with binary data?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk:Photo -data with binary data?
by BrowserUk (Patriarch) on Dec 13, 2006 at 11:31 UTC | |
That's really good to know. Thanks. I would have raised this as bug report but it was never clear whether the 'bug' was just my misinterpretation of the docs--plenty of other people assumed that 'binary data' meant base64 encoded binary data--, a deliberate omission, or a limitation of the underlying Tk libraries. If you have any influence with those that will implement this? What would be *really nice*, would be the possibility to (alternatively) pass the address of a buffer from which Tk would update the underlying windows bits when instructed. In an ideal world, it would be possible to use a graphics (painting) tool, (like GD) to create and/or modify images and a presentation tool (like Tk) to display them; with having to go through multiple copy operations and format conversions to pass data between them. Presumably, all Tk::Photo does with the data passed is convert it into the format required by the underlying OS window primitives (eg. Bitmap for windows), and then pass the converted data on to the OS for display. Tk::Photo makes use of several packages (Tk::Png, Tk::Jpeg etc.) to do the conversion. GD uses an internal format of it's own making (the GD(1) format). I'm wondering about the possibility of adding a Tk::GD package to the suite? If (a to be written) Tk::GD package could accept an address, and the authors of GD/bgd could be pursuaded to expose the address of their internal buffers, then once the connection was made, you could use GD to modify the image and simple force an update to the Tk::Photo widget to have it read the bits directly out of the GD buffer. That would save several copy and convert steps along the way. The current situation of either: makes using Tk for graphical applications (rather than window/dialog building purposes for which it is really quite nice), a PITA. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by eserte (Deacon) on Dec 13, 2006 at 20:53 UTC | |
As for the Tk::GD thing, I think this should be possible. Tk has various image types (Bitmap, Pixmap, Photo). And for Photo, there are various handlers for different image formats (gif, jpeg, png ...). It seems that Tk::GD should be implemented as another image type. You can look at tixGeneric/tixImgXpm.c or generic/tkImgPhoto.c in the Perl/Tk sources to see how to do this. | [reply] |
by eserte (Deacon) on Dec 13, 2006 at 23:39 UTC | |
I found that the internal Tk image handling code is already binary-ready, at least for the GIF format. Unfortunately Perl/Tk converts every string into a utf8-flagged string, which means that the data has again to be converted back to bytes before handing to the image handling code, which consumes space and time. It seems to be non-trivial to avoid these unnecessary conversions.
| [reply] [d/l] |
by BrowserUk (Patriarch) on Dec 14, 2006 at 05:13 UTC | |
by eserte (Deacon) on Dec 14, 2006 at 23:47 UTC | |
| |
by eserte (Deacon) on Dec 14, 2006 at 23:50 UTC | |