How to post on this page editPlease do not edit this part, it is meant as a guide!
- Started on: 2018 April 16th
- Ended on: ...
- Previous : Ask, and it shall be given # 12
- Next page: ...
This page runs the risk of being deleted and corrupted. Please be very careful when editing it. If you inadvertently delete it, immediately revert your edit using the History link on the left side of this page.Do NOT attempt to restore it by copying and pasting the text from a previous revision, or all page formatting will be lost!Please put new questions at the TOP of the page, below this section, so that as the page grows longer, new questions are seen first.Also please put a section header on top of every question and put two stars in the beginning of the title and two stars in the end. This will make your question's section easily editable.Once you have received a satisfactory answer, please cut your question and answer directly on an appropriate page of the wiki. If you cannot find an existing page, create a new one.You might also simply want to put a hyperlink leading to a page of the wiki where your question is included. This will save you the trouble of cutting your question to an existing page afterwards.Put your question below. Thanks!
<<Selection>> event for entryHi, has anyone written a script to add selection events like those for text widget to a one-line entry? (Or should I simply create a 1-line text instead?)
Hex String to Doublebeware Hi all, I'm trying to decode some files. One of the values I need is stored as a double in hex. Example - "3fb999999999999a" -> "0.1". The double conversion here gets the correct result: https://gregstoll.dyndns.org/~gregstoll/floattohex/ currently my code just has the hex stored as a string (as in "set hexstr 3fb999999999999a"). How do I replicate the conversion done on that site?Martyn Smith The TCL command is binary, you need to convert the hexadecimal string to a binary string with binary format then extract the big endian double from the binary string as follows
binary scan [binary format H* $hexstr] Q floatValueThe Q is the format code for forced big endian double.
Google PhotosHas anyone written a tcl library that interfaces with [Google Photos] to allow one to download a "table of contents" of URLs to images and the albums to which they belong?
Image ScalingMiR 2018-06-28:On topic image scaling...I was wondering, if Tk would in the future implement at least a robust image scaling alogrithm like in TkImageTools from (reference see Shrinking an image)? It's just to avoid having to deploy an externel dynamic library just to have an image resized...AMG I did this just yesterday, but I'm probably not allowed to share the code though. I used libsamplerate  to do it. The interface works like this:[imgscale sourcePhoto targetPhoto ?method?]sourcePhoto and targetPhoto can be one-, three-, or five-element lists:
- operate on full extents of photo
- photoName width height
- explicit width and height, top left defaults to (0,0)
- photoName left top width height
- explicit width, height, and top left coordinates
- Use the Simple API  which consists of only the src_simple() function. The more complicated APIs offer no benefit in this application because the image data is all available in advance.
- Work on one channel (R, G, B, A) at a time. This requires less temporary space and offers better performance due to improved locality of reference and ability to use more optimized single-channel code within libsamplerate.
- Step 1: Loop over each row of input R, G, B, or A bytes.
- Step 1a: Convert the input row into a linear buffer of floats.
- Step 1b: Rescale the width and store into an intermediate float buffer large enough to hold the whole channel.
- Step 2: Transpose the intermediate buffer so that each column is contiguous in memory.
- Step 3: Loop over each column of intermediate floats.
- Step 3a: Rescale the height and store into a linear buffer of floats.
- Step 3b: Convert the scaled column back into pixel bytes, storing into a pixel buffer large enough for the whole image.
- Step 4: Use Tk_PhotoPutBlock() to write the pixel buffer to the target photo.
pitch = 1 pixelSize = height offset[n] = n * height * widthOne other tip. I statically linked libsamplerate into my extension. Another possibility is to incorporate a subset of the source code, removing the unused SINC modes, to avoid their large coefficient tables. (BSD 2-clause license, by the way.)