How to post on this page edit
Please 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: ...
Page contents
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!
Questions edit
Intercept/Observe command-line -geometry
Duoas 2018-10-16 Hey there. Is there any way to intercept/observe the processing of -geometry arguments at the command line when wish (tclkit) starts, not involving binary extensions or hacking the core?I would like to permit multiple -geometry options to manage multiple windows (order/matching windows does not matter — they appear as clones). I can query the last supplied geometry with $::geometry, of course. I’ve tried both traces and pkgIndex.tcl trickery, but the Initialize() function in ~/generic/tkWindow.c appears to get called before any kind of user code gets a chance. Is this correct? Am I out of luck here?If it makes any difference I am packaging in a starkit.bll 2018-10-16 I think you will have to have the user put the -geometry arguments on the command line after a -- argument and process them yourself. There's no way to have wish do unusual things with its command line arguments.<<Selection>> event for entry
Hi, 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 Double
beware 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 followsbinary scan [binary format H* $hexstr] Q floatValueThe Q is the format code for forced big endian double.
Google Photos
Has 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 Scaling
MiR 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 [1] to do it. The interface works like this:[imgscale sourcePhoto targetPhoto ?method?]sourcePhoto and targetPhoto can be one-, three-, or five-element lists:- photoName
- 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 [2] 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.)Duoas 2018-10-19 Actually, was just working on a small binary extension to do the same thing, photo-resample.kit. Permits scaling using nearest neighbor, linear, cubic, box, and hqx algorithms, plus mirror and rotate, plus a few other resampling goodies like sharpen, gaussian blur, colorizing, desaturating, inverting an image, splitting and combining channels and alpha channel manipulations, and origin tracking, all with a very simple interface.