WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Simple Magnifier  (Read 2234 times)

Offline socks

  • Newbie
  • *
  • Posts: 15
Simple Magnifier
« on: January 03, 2023, 10:51:03 PM »
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: [Select]
#!/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"
  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: [Select]
#!/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
  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


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11660
Re: Simple Magnifier
« Reply #1 on: January 04, 2023, 12:19:19 AM »
Hi socks
... 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. ...
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. ...
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. ...
Hitting  Ctrl-Alt-M  once or twice will get a window back onto the screen.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11048
Re: Simple Magnifier
« Reply #2 on: January 04, 2023, 03:25:54 AM »
There is a magnifier tool, xmag. You may need to compile it.
The only barriers that can stop you are the ones you create yourself.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 718
Re: Simple Magnifier
« Reply #3 on: January 04, 2023, 04:13:32 AM »
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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11660
Re: Simple Magnifier
« Reply #4 on: January 04, 2023, 10:08:53 AM »
Hi patrikg
... Here the stream with the programmer program that program.
https://www.twitch.tv/collections/HlRy-q69uBXmpQ
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.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 718
Re: Simple Magnifier
« Reply #5 on: January 04, 2023, 10:58:59 AM »
Hi Rich

Sorry Rich, to not provide the specific time where the very specific location/timestamp where there are some demo of that program.

And I don't title the link with that either.
- "Here the stream with the programmer program that program".   

TLDW:
There some interesting stuff in this vod, using another programming language rather than c and c++ when programming.

Maybe my written English is not the very best, sorry for that to.
« Last Edit: January 04, 2023, 11:11:00 AM by patrikg »

Offline socks

  • Newbie
  • *
  • Posts: 15
Re: Simple Magnifier
« Reply #6 on: January 08, 2023, 11:16:53 PM »
Thank you all for the suggestions.

Rich,
  I new about grabber, but decided to start with windowshot so as avoid extra input parameters and focus on the task of gluing things together with a script, an area I'm very new to.
  PicFormat does indeed do an acceptable job of fractional magnification. I tested with 130% , the slight fuzziness is not distracting, so I may end up with something incorporating that and grabber.

  Following up Curaga's suggestion I came across xzoom in the form of a minor addition to xmag
I was able to test it in a TC FLWM context using dcore stretch 32 bit.
  Xzoom does everything I had hoped for and a bit more. Besides being able to resize and reposition the viewing window and the target area, one can scroll thru a long list and easily spot items of interest in the dynamic magnified view. While xzoom.sce is 20 meg or so, I suspect most of that is already in the xorg packages, so perhaps a .tcz is not too difficult to arrange.

  I wonder if it is possible to set up a dynamic connection between a target window and a display window in the FLWM context with out the aid some weighty management program?
I thought of a very primitive way to do that and did a crude initial test, but xzoom already does it with apparently not much overhead.

Sean