After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685548 - imagecapture x,y offset, height and width parameters are disregarded if window parameter is provided
imagecapture x,y offset, height and width parameters are disregarded if windo...
Status: RESOLVED FIXED
Product: LDTP
Classification: Other
Component: ldtp2
head
Other All
: Normal normal
: head
Assigned To: LDTP maintainers
LDTP Development Mailing List
Depends on:
Blocks:
 
 
Reported: 2012-10-05 10:06 UTC by Marek Rosa
Modified: 2012-10-08 19:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix to imagecapture() (5.95 KB, patch)
2012-10-08 13:56 UTC, Marek Rosa
none Details | Review

Description Marek Rosa 2012-10-05 10:06:23 UTC
image capture offset, width and height parameters are only used when whole desktop image capture is taken.

imagecapture(windowName, outputFile, offsetX, offsetY, captureWidth, captureHeight)

When the windowName parameter is provided then whole window capture is taken regardless of what the offsets, width and height parameters are.

When the windowName parameter is omitted then the offsets, width and height parameters are respected

It works fine when following line in ldtpd/generic.py (line 85) is changed from:

x, y, height, width = bb.x, bb.y, bb.height, bb.width

to something like this:

x, y = x + bb.x, y + bb.y
if height > bb.height:
    height = bb.height
if width > bb.width:
    width = bb.width

Thanks.
Comment 1 Nagappan Alagappan 2012-10-07 05:53:39 UTC
Fixed the bug in git head, thanks for the bug report with the patch.
Comment 2 Marek Rosa 2012-10-08 13:56:58 UTC
Created attachment 226041 [details] [review]
Proposed fix to imagecapture()

This is how it works:

imagecapture() - captures the whole desktop
imagecapture(window_name) - captures the window. If the window is over the edge or oversized - clip it. Do not fill with black.

Customized capture:
imagecapture(x, y, width, height)
negative x, y are defaulted to 0
width and height which are less than 1 are defaulted to None - whole window or desktop in that orientation is captured.
If x >= width then x = width - 1
If y >= height then y = height - 1
at least one pixel has to be captured.
Comment 3 Marek Rosa 2012-10-08 13:57:41 UTC
The fix I proposed is not good. Sorry for that.
Now it doesn't work correct if width and height parameters are omitted in the imagecapture() call.
I have fixed that in the attached patch.

There is few more things I noticed.

At the moment it is possible to provide negative offset values.
In case of a window it will capture what is around the window.
In case of the desktop screen capture it fills the extra space with black color (at least on ubuntu 12.04)

Is this a desired behaviour or should it default to 0 if negative values are provided?
This also applies to height and width parameters. 
Captured image should not be bigger than the window/desktop size

I haven't really done much with LDTP so far. Is there a use case for that?

I have created a patch that assumes only real content is captured (no extra black frame)

I hope this is how it should work. If not then please revert the previous commit. It is not good.
Thanks.
Comment 4 Marek Rosa 2012-10-08 14:01:11 UTC
Once again. Haven't used bugzilla before.
Comment 3 should go before comment 2.

The original fix (in the bug description is wrong.)
The new one should be fine.
Sorry once again for the unnecessary extra mails.

Regards,
Marek
Comment 5 Nagappan Alagappan 2012-10-08 19:21:28 UTC
(In reply to comment #4)
> The original fix (in the bug description is wrong.)
> The new one should be fine.

Thanks for the updated patch, fixed it git head

> Sorry once again for the unnecessary extra mails.

No issues :-)

Thanks