Skip to content

Commit 98f3443

Browse files
committed
Corrected image cropping coordinates
- Version 4.10.2
1 parent 8efa4ec commit 98f3443

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

AndroidViewClient/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
setup(name='androidviewclient',
6-
version='4.10.1',
6+
version='4.10.2',
77
description='''AndroidViewClient is a 100% pure python tool that
88
simplifies test script creation providing higher level operations and the ability of
99
obtaining the tree of Views present at any given moment on the device or emulator screen.

AndroidViewClient/src/com/dtmilano/android/viewclient.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '4.9.0'
21+
__version__ = '4.10.2'
2222

2323
import sys
2424
import warnings
@@ -43,7 +43,7 @@
4343
import xml.parsers.expat
4444
from com.dtmilano.android.adb import adbclient
4545

46-
DEBUG = False
46+
DEBUG = True
4747
DEBUG_DEVICE = DEBUG and False
4848
DEBUG_RECEIVED = DEBUG and False
4949
DEBUG_TREE = DEBUG and False
@@ -869,7 +869,16 @@ def writeImageToFile(self, filename, format="PNG"):
869869
filename = os.path.join(filename, self.variableNameFromId() + '.' + format.lower())
870870
if DEBUG:
871871
print >> sys.stderr, "writeImageToFile: saving image to '%s' in %s format" % (filename, format)
872-
self.device.takeSnapshot().getSubImage(self.getPositionAndSize()).writeToFile(filename, format)
872+
#self.device.takeSnapshot().getSubImage(self.getPositionAndSize()).writeToFile(filename, format)
873+
# crop:
874+
# im.crop(box) ⇒ image
875+
# Returns a copy of a rectangular region from the current image.
876+
# The box is a 4-tuple defining the left, upper, right, and lower pixel coordinate.
877+
((l, t), (r, b)) = self.getCoords()
878+
box = (l, t, r, b)
879+
if DEBUG:
880+
print >> sys.stderr, "writeImageToFile: cropping", box
881+
self.device.takeSnapshot().crop(box).save(filename, format)
873882

874883
def __smallStr__(self):
875884
__str = unicode("View[", 'utf-8', 'replace')

0 commit comments

Comments
 (0)