Author Topic: Capture window that extend beyond the active desktop  (Read 12621 times)

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Capture window that extend beyond the active desktop
« on: August 11, 2018, 08:50:30 am »
Hello,

I've written a .dll to capture and resize images and it work as expected.
I've now created an application that use it, and I consider it finished, but it can draw a window that is larger than the screen/desktop.
The problem is that parts of the window that extend beyond the edge of the desktop doesn't get filled with what the window contain, just a black background.
PMView seem to have a solution for it... to flip between the XPager pages that the window extend to, to capture and assemble the parts.
Isn't there a neater solution?
How can it be done either way?

Jan-Erik

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #1 on: August 11, 2018, 05:16:46 pm »
Example

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #2 on: August 11, 2018, 05:38:54 pm »
What about using ALT-F7 to move the window around so that it all eventually is on the visible desktop? Does the parts that are on screen and then once again off screen stay drawn or revert to black?

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #3 on: August 11, 2018, 11:18:57 pm »
My screen resolution is only 1366x768 on this laptop.
The application detach the viewport and place it at coordinate 0,0 (lower left corner of the desktop) and with the width and height needed.
It take the snapshot and then restore the size and position of the viewport (See 1_orion_1.mpg.png to 3_orion_1.mpg.png for the viewport).

Image/Window size (1 and 2 was switched below and referred to each other, now corrected)

¹) The selected "DropShadow" background in the Example image use 204x156 pixels
The text at the top use 100 pixels and margins add 10 pixels.
See 2_orion_1.mpg.png and the corresponding MCS2.png
width = 10 + 5 × 204 = 1030              ( OK since 1030 < 1366 & 734 < 768 )
height = 10 + 100 + 4 × 156 = 734
See 1_orion_1.mpg.png and the corresponding MCS1.png

²) Each of the 20 images use 320x240 pixels by default without a background "frame".
The text at the top use 100 pixels and margins add 10 pixels.
width = 10 + 5 × 320 = 1610              ( Not OK since 1366 < 1610 & 768 < 1070 )
height = 10 + 100 + 4 × 240 = 1070
See 2_orion_1.mpg.png and the corresponding MCS2.png

³) But another background image can dictate that each frame (with spacing) should be larger and thus extend even further (400×280 pixels)
The text at the top use 100 pixels and margins add 52 pixels.
See 3_orion_1.mpg.png and the corresponding MCS3.png
« Last Edit: August 12, 2018, 06:11:09 am by Jan-Erik Lärka »

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #4 on: August 11, 2018, 11:20:51 pm »
The parts that show on screen can bee seen while the other parts stay black.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #5 on: August 12, 2018, 01:17:22 pm »
Executable to try

Prerequisites
https://github.com/OS2World/LIB-REXX-RxImgSize
and Chris Wolgemuth's DrCtrl 0.1.7 and ffmpeg
« Last Edit: August 12, 2018, 08:24:18 pm by Jan-Erik Lärka »

Andy Willis

  • Sr. Member
  • ****
  • Posts: 292
  • Karma: +7/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #6 on: August 12, 2018, 05:57:05 pm »
I do not know the answer to your question, other than to guess it will need to be something like what PMView implemented.
Latest Gotcha release, has the black bar for parts of the window off screen.
PMCamera cuts the window off at the screen border without any black bar filling where the rest of the window was at offscreen.
PMView, as you stated, captures the entire window, including the offscreen portion - I don't know how they are accomplishing it.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #7 on: August 12, 2018, 08:34:18 pm »
I do not know the answer to your question, other than to guess it will need to be something like what PMView implemented.
Latest Gotcha release, has the black bar for parts of the window off screen.
Yes, verified it too.
PMCamera cuts the window off at the screen border without any black bar filling where the rest of the window was at offscreen.
PMView, as you stated, captures the entire window, including the offscreen portion - I don't know how they are accomplishing it.
Enlarge your Firefox/Seamonkey window over 2 or more XPager pages, the more the better.
Enable screen capture of program window in PMView and activate it.
Here it flip around and trigger all pages in sequence that the window span over.

is the current Active XPager view present in OS2.INI, OS2SYS.INI or somewhere else so that one can query it, change the value and post a message to xwpdeamon to switch page?
The problem then is to stitch all those image pieces together.  :(

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #8 on: August 12, 2018, 10:19:08 pm »
is the current Active XPager view present in OS2.INI, OS2SYS.INI or somewhere else so that one can query it, change the value and post a message to xwpdeamon to switch page?
My ideas:

That method looks wrong. It looks to me as follows: XPager just queries the size of desktop windows, relative to the current desktop (work)area. You have to query the correct window size. XPager or XWP are not involved.

Querying the window size looks easy. But apparently, only the visible window parts are painted. Does a function exists that causes a window to repaint, disregarding the desktop size? Would it help to invalidate the contents of the window rectangle?

xynixme

  • Guest
Re: Capture window that extend beyond the active desktop
« Reply #9 on: August 12, 2018, 10:57:09 pm »
Quote
XPager or XWP are not involved.
Exactly. With ePager and a small window in the bottom right corner, the background changes and ePager disappears. Sending magic keystrokes to ePager's window isn't the magic solution. With ePager-switches the desktop background image remains the same, and you can always see the ePager window.

Presumably PMView calculates where the window is, switches to those desktops by itself, and merges the images indeed.

xynixme

  • Guest
Re: Capture window that extend beyond the active desktop
« Reply #10 on: August 12, 2018, 11:05:38 pm »
Quote
Enlarge your Firefox/Seamonkey window over 2 or more XPager pages, the more the better.
FWIW: any small window in one of the corners can include 4 desktops, and those desktops can be out of range for ePager. With a smaller window it's easier to see that the background images changes, unlike ePager's mode of operation, at least with my default install of eCS 1.2 with the default desktop background settings.

FWIW/2: most sample images weren't that clear, because black was also the background color of space.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #11 on: August 13, 2018, 07:33:10 pm »
But you did try what I suggested?

My application MCS can of course move around the viewport (window) on the current desktop to display the portions that extend over the edge, but the big problem then remain, to stitch all those parts together into one image.

Would you please help me write the code to merge multiple captured images together and exclude black areas?

xynixme

  • Guest
Re: Capture window that extend beyond the active desktop
« Reply #12 on: August 13, 2018, 11:40:16 pm »
Quote
But you did try what I suggested?

Would you please help me write the code to merge multiple captured images together and exclude black areas?

What did you suggest? Or are you trying to say that you can capture all desktops, but that cropping and merging is the problem?

I don't know what you mean by "exclude black areas"? Surely you don't want me to write yours (no GCC DLLs, 1.5 supported different bitmap file formats, exactly 1 desktop size-related API in use), and I'd consider using NCONVERT or tools like that. If you cannot calculate which part of each bitmaps you need, then features like its crop or autocrop (cropping) and watermark (merging) may be helpful somehow. And I was just saying that ePager isn't involved, a.o. based on the desktops' background.

A reason why I'm supporting 1.5 file formats is that other software does a good job. I do use code to "exclude areas of a specific color", but that should be quite simple with a bitmap and it's probably a different type of cropping. Software other than NCONVERT may even be better, but I stopped looking after seeing its features.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #13 on: August 20, 2018, 07:44:33 pm »
Here's the updated version.
It can load images or movies and create multiple images if they extend beyond the desktop.
Placed in the folder "STITCH" (%HOME%\.cache\ContactSheet)
Would be nice if you that try it would addcapability to the library rxImgSze to either grab the window directly or to stitch the images into one.

Regards,
Jan-Erik Lärka
« Last Edit: August 20, 2018, 07:53:08 pm by Jan-Erik Lärka »

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: Capture window that extend beyond the active desktop
« Reply #14 on: August 20, 2018, 10:42:41 pm »
What did you suggest?
Enlarge your Firefox/Seamonkey window over 2 or more XPager pages, the more the better.
Enable screen capture of program window in PMView and activate it.
Here it flip around and trigger all pages in sequence that the window span over.

I'd be quite surprised if PMView is responsible for moving the Firefox main window as well hide/show all other open windows to achieve it! Calling/Triggering XPager is therefore more likely.

Or are you trying to say that you can capture all desktops, but that cropping and merging is the problem?

Yes, merging multiple captured images is the current problem now as I've adjusted the code to move the viewport around on the active desktop until it has captured all required parts. It doesn't handle other application windows that is in the way.
It use the full size needed for the desired window and move it around. The result is that each image will contain black area(s) and one part that was visible for that specific move. If one combine the non black parts, exclude the black area(s) that is, of the images, one get the complete one.

I don't know what you mean by "exclude black areas"? Surely you don't want me to write yours (no GCC DLLs, 1.5 supported different bitmap file formats, exactly 1 desktop size-related API in use), and I'd consider using NCONVERT or tools like that. If you cannot calculate which part of each bitmaps you need, then features like its crop or autocrop (cropping) and watermark (merging) may be helpful somehow. And I was just saying that ePager isn't involved, a.o. based on the desktops' background.

My Rexx image support dll "rxImgSze" rely on gbm and handle enough file formats. Just need to add C/C++ code to it to either grab what I want somehow or stitch parts (see attached example images) together.
It would be a lot better if one could get the full image as I have the window handle and not just the visible portion.
How can one print or use windows that extend beyond the desktop to retrieve their bitmap representation?