WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Creating a "windowshot" instead of a screenshot  (Read 12518 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Creating a "windowshot" instead of a screenshot
« on: March 19, 2013, 03:27:45 AM »
This is a modified version of screenshot.sh that will produce a png of the window you click on. It depends on xwininfo
to run so you need to install xorg-7.(5 or 6)-bin.tcz only.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #1 on: March 19, 2013, 03:33:05 AM »
I forgot to mention, if you click on the desktop, it will create a screenshot.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #2 on: March 19, 2013, 04:22:14 AM »
Excellent! :D

One observation: the aterm from which command is executed must not overlap the window clicked on, or it would end up being included in the windowshot.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #3 on: March 19, 2013, 06:57:11 AM »
Hi tinypoodle
That is correct. The "picture" will be of whatever is visible on the screen inside the coordinates of that particular
window.
« Last Edit: March 19, 2013, 07:04:36 AM by Rich »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #4 on: March 19, 2013, 07:00:59 AM »
Not being Rich but just assuming you were replying to my post...

Also, I found that areas of windows outside screen borders will be painted gray.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline beroje

  • Full Member
  • ***
  • Posts: 130
Re: Creating a "windowshot" instead of a screenshot
« Reply #5 on: March 19, 2013, 07:09:29 AM »
very good
Two windows, one superimposed on the other.
Clicking on the rear window also captures the front.

Muy bueno
Dos ventanas, una superpuesta a la otra.
Al hacer clic en la ventana posterior tambien se captura la frontal.



Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #6 on: March 19, 2013, 07:12:37 AM »
Hi tinypoodle
Quote
Not being Rich but just assuming you were replying to my post...
Lack of sleep, copied/pasted the wrong name, corrected.

That's because  imlib2_grab  can only save what is painted on the screen, but since it uses the windows coordinates
and dimensions, it fills in what it can't read in gray. In fact, I once read through some of the documentaion for
imlib2_grab  and I seem to recall it was mention there too.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #7 on: March 19, 2013, 07:13:44 AM »
Hi beroje
Glad you like it.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #8 on: March 19, 2013, 07:16:32 AM »
That makes all sense and still an advantage over having a full screenshot when only a window is required.
I'd assume the gray areas should be well compressible by png.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #9 on: March 19, 2013, 07:29:28 AM »
Hi tinypoodle
Quote
I'd assume the gray areas should be well compressible by png.
Not as much as you might think. I took the same shot as the one attached to my first post but with the window
halfway off the screen and the file size went from ~16K to ~15K. On my system the off screen section was black.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #10 on: March 19, 2013, 07:33:51 AM »
The semantic difference between "assume" and "test"... :P

And probably black is preferable over gray as look.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #11 on: March 19, 2013, 07:37:27 AM »
Hmm, I got 68Kb with an estimated quarter of window visible versus 171Kb with same full window, so I guess it may depend.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Creating a "windowshot" instead of a screenshot
« Reply #12 on: March 19, 2013, 12:52:55 PM »
Hi tinypoodle
The results I got may be do to the fact that I used the editor with just the posted script in it. I slid the window to the
right obscuring the right half of the window which consisted of a lot of white space and may have already compressed
fairly well when doing a capture.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Creating a "windowshot" instead of a screenshot
« Reply #13 on: March 19, 2013, 01:08:23 PM »
Such factors most likely could explain the differences.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline hiro

  • Hero Member
  • *****
  • Posts: 1217
Re: Creating a "windowshot" instead of a screenshot
« Reply #14 on: March 19, 2013, 03:38:18 PM »
Elegant. I'm using it as my default from now on, but I removed the sleep.