in reply to Tk:Photo -data with binary data?
Or use the handy bintoscalar utility...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk:Photo -data with binary data?
by BrowserUk (Patriarch) on Nov 28, 2006 at 21:26 UTC | |
I actually do mean binary data, per the Tk::Photo docs:
I have the image data in memory, and wish to avoid either writing it to a file or converting it to base64. 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 liverpole (Monsignor) on Nov 28, 2006 at 23:10 UTC | |
and in the next paragraph ...
I'm assuming you know what the image format is of the image you have in memory. Why not just try displaying the image yourself? As the Tk documentation illustrates, you can use:
and if necessary supply -format => FORMAT (for one of the valid IMAGE FORMATS above). Have you tried doing that yet? s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/ | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Nov 28, 2006 at 23:38 UTC | |
Yes, I've tried that too. The following example works if you switch the comment cards to encode the data base64, but not without. I've also tried various different formats that GD support (.jpg, .gif). The result is always couldn't recognize image data at c:/Perl/site/lib/Tk/Image.pm line 21, which is annoying because it can read that same data back from a file, with or without a format hint. It seems strange that is can read the data from a file, but not directly from memory. If the -file option would take a file handle instead of a name, I could throw the data into a ramfile, but it doesn't :( The time taken to convert the image to base64 to pass it into tk--where it is presumably converted straight back again--thrashes the cpu to death and really slows things down of you are trying to update the image quickly.
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] [d/l] [select] |
by calin (Deacon) on Nov 28, 2006 at 22:44 UTC | |
Dunno, the following example should work but it doesn't. It seems that some formats can't read data from strings, for whatever reasons. This is somewhat hinted in the docs: data => string
It dies with the error:
If I dump $fdata to a file and then use -file => ..., it works. | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Nov 28, 2006 at 23:42 UTC | |
Yes. That's the same results I am getting. See Re^4: Tk:Photo -data with binary data?. It seems strange that there would have to be special handling for binary data from a string, when it can handle that same binary data froma file. It should only need to detect the presence of non-base64 characters in the data supplied? 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] |