OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 Bitmap is a basic wrapper for image pixels. It includes some basic processing | 6 Bitmap is a basic wrapper for image pixels. It includes some basic processing |
7 tools: crop, find bounding box of a color and compute histogram of color values. | 7 tools: crop, find bounding box of a color and compute histogram of color values. |
8 """ | 8 """ |
9 | 9 |
10 import array | 10 import array |
11 import base64 | 11 import base64 |
12 import cStringIO | 12 import cStringIO |
13 import struct | 13 import struct |
14 import subprocess | 14 import subprocess |
15 | 15 |
| 16 from telemetry.core import platform |
16 from telemetry.core import util | 17 from telemetry.core import util |
17 from telemetry.core import platform | |
18 from telemetry.image_processing import histogram | 18 from telemetry.image_processing import histogram |
19 from telemetry.image_processing import rgba_color | 19 from telemetry.image_processing import rgba_color |
20 from telemetry.util import support_binaries | 20 from telemetry.util import support_binaries |
21 | 21 |
22 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'png') | 22 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'png') |
23 import png # pylint: disable=F0401 | 23 import png # pylint: disable=F0401 |
24 | 24 |
25 | 25 |
26 class _BitmapTools(object): | 26 class _BitmapTools(object): |
27 """Wraps a child process of bitmaptools and allows for one command.""" | 27 """Wraps a child process of bitmaptools and allows for one command.""" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 if (left < 0 or top < 0 or | 227 if (left < 0 or top < 0 or |
228 (left + width) > cur_width or | 228 (left + width) > cur_width or |
229 (top + height) > cur_height): | 229 (top + height) > cur_height): |
230 raise ValueError('Invalid dimensions') | 230 raise ValueError('Invalid dimensions') |
231 | 231 |
232 self._crop_box = cur_left + left, cur_top + top, width, height | 232 self._crop_box = cur_left + left, cur_top + top, width, height |
233 return self | 233 return self |
234 | 234 |
235 def ColorHistogram(self, ignore_color=None, tolerance=0): | 235 def ColorHistogram(self, ignore_color=None, tolerance=0): |
236 return self._PrepareTools().Histogram(ignore_color, tolerance) | 236 return self._PrepareTools().Histogram(ignore_color, tolerance) |
OLD | NEW |