General TC > Programming & Scripting - Unofficial

Simple Magnifier

(1/2) > >>

socks:
This simple magnifier, is a modification of Richard Rost's Widowshot. http://forum.tinycorelinux.net/index.php/topic,15086.0.html
  It may help some users of TinyCore who, like myself, have difficulty with the font used in the builtin FLTK tools.   
  Every year or so I attempt to find out how to change the font in FLTK/Fluid, but at low level, the documentation is at best sketchy, possibly non-existent. This time round I thought 'why not just enlarge the problem windows ?'.
I had in mind a script using dimly remembered Windowshot followed by convert from Imagemagik, and then an image viewer.
  However I soon realized that something much simpler would probably do what I had in mind.
Windowshot is basically a shell script that uses imlib2_grab to save its target while imlib2_view, also part of TC's the imlib2 extension, can resize the image you give it to display.
  So we have :

--- Code: ---#!/bin/sh
# Script to capture a single window and display it doubled in size.
# When run, the cursor changes to a crosshair.
# Click on the target window and the cursor will revert to normal.
#
[ -z ${DISPLAY} ] && echo "Requires X" &&  exit 1
which xwininfo > /dev/null
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5 or 6)-bin.tcz" &&  exit 1
#
WINDOW_ID=`xwininfo -frame | grep " Window id:" | cut -d " " -f 4`
/bin/sh -c "imlib2_grab -id $WINDOW_ID /tmp/image.png"
/bin/sh -c "imlib2_view -s 2 /tmp/image.png"

--- End code ---
  Enlargement by two is much more than I need, but fractional values between 1 and 2 result in ragged distracting symbols. The imlib2 builtin algorithm is too crude to do a neat job on black and white .pngs using an enlargement factor like 1.3 say. Perhaps someone knows of a better algorithm, readily available or easily implemented ?

  This simple modification of Windowshot works well enough, but if the enlarged window is too big or you accidentally select the desktop, everything on the desktop is blanked out and the mouse is useless.
  Another gem from Rich is a list of keyboard based window controls that I had stashed for just this moment.
CTL ALT - , (the minus close to P, not the one near the number-pad) reduces the height of the window.
One or two repeats make the top edge of the frame accessible, the mouse is now able to sort things out.
  So I added some warnings and reminders. It took quite a while to find out how to get a popup to actually end up on top of everything else and even more time to have it appear only when really needed.
  The display height comes from xdpyinfo while the target window height comes from xwininfo. Relying on the layout of these files to extract the numbers is not very robust but will do for now.
  So we arrive at :

--- Code: ---#!/bin/sh
# Based heavily on Tinycore's windowshot, this script captures a
# single window and displays it doubled in size. When run, the cursor
# changes to a crosshair and the target screen is selected by cilcking on it.
#
# The enlarged image can fill the display effectively disabling the mouse.
# To recover control, click on the image and use the Ctl Alt ' - ' key combination.
# This shrinks the the window and gives access to the top edge of the frame.
#
[ -z ${DISPLAY} ] && echo "Requires X" &&  exit 1
which xwininfo > /dev/null
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5 or 6)-bin.tcz" &&  exit 1
HH=`xdpyinfo | grep dimensions: | cut -c 23-26`
#xdpyinfo | grep dimensions: | cut -d " " -f 4-7 | cut -d x -f 2
#
xwininfo -frame > data
WINDOW_ID=`grep " Window id:" data | cut -d " " -f 4`
H=`grep "Height:" data | cut -c 11-`; hh=$((2*H + 10))
#W=`grep "Width:" data | cut -c 10-`
/bin/sh -c "imlib2_grab -id $WINDOW_ID /tmp/image.png"
/bin/sh -c "imlib2_view -s 2 /tmp/image.png"  &
sleep 0.1
if [ $hh -gt $HH ]; then popup "Click on image, then use 'Ctrl Alt - '  to access frame"; fi

--- End code ---
  No doubt the above can streamlined. This code is the result of trial and error on top of imitation. 
I don't think the construction '/bin/sh -c " commands " ' is really needed in this context.
  I read that the full version of Imlib2_view allows you to control the display window size and position but I guess FLWM ignores the guidance so those parameters are absent in the TC version.
  I think there is a way to use Xmessage instead of popup to give more convenient control of the magnifier in actual use. Xmessage can have buttons that could allow a choice to close the mag session or magnify new content after scrolling the target. That is the next thing to do.
  Once its working as I want, I'll submit an extension.

Sean

Rich:
Hi socks

--- Quote from: socks on January 03, 2023, 10:51:03 PM --- ... Enlargement by two is much more than I need, but fractional values between 1 and 2 result in ragged distracting symbols. The imlib2 builtin algorithm is too crude to do a neat job on black and white .pngs using an enlargement factor like 1.3 say. ...
--- End quote ---
Maybe it's not the imlib2 algorithm but how  imlib2_view  is using it. See if  PicFormat.tcz  does
a better job. It can resize images and change image formats (png, jpg, etc.). Read the
PicFormat.tcz.info  file for full details.


--- Quote --- ... This simple modification of Windowshot works well enough, but if the enlarged window is too big or you accidentally select the desktop, everything on the desktop is blanked out and the mouse is useless. ...
--- End quote ---
If you want something more fine grained, try  grabber.tcz.  It allows you to select an area of
the screen with your mouse and save it. Read the  grabber.tcz.info  file for full details.


--- Quote --- ... Another gem from Rich is a list of keyboard based window controls that I had stashed for just this moment.
CTL ALT - , (the minus close to P, not the one near the number-pad) reduces the height of the window.
One or two repeats make the top edge of the frame accessible, the mouse is now able to sort things out. ...
--- End quote ---
Hitting  Ctrl-Alt-M  once or twice will get a window back onto the screen.

curaga:
There is a magnifier tool, xmag. You may need to compile it.

patrikg:
I have seen some great youtuber/twitcher program to zoom on X using his own program(boomer)
If you don't need to save the file, and using a flashlight point to magnify where to look.

Don't know if if it's possible to compile that program on tc.
Here are his link to github page to the program.
https://github.com/tsoding/boomer
It's compiled with programming language nim. https://nim-lang.org/

Here the stream with the programmer program that program.
https://www.twitch.tv/collections/HlRy-q69uBXmpQ

Rich:
Hi patrikg

--- Quote from: patrikg on January 04, 2023, 04:13:32 AM --- ... Here the stream with the programmer program that program.
https://www.twitch.tv/collections/HlRy-q69uBXmpQ
--- End quote ---
I was expecting to see a brief demonstration of a zoom program but was
confronted with a 3 hour video. After 15 minutes of this stoner rambling
on, I finally shut it down.  ::)
If there's something you wanted to call attention to in that video, provide
a time stamp to that location.

Navigation

[0] Message Index

[#] Next page

Go to full version