1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import division
6
7from telemetry.internal.image_processing import _bitmap
8
9
10def Channels(bitmap):
11  return bitmap.bpp
12
13def Width(bitmap):
14  return bitmap.width
15
16def Height(bitmap):
17  return bitmap.height
18
19def Pixels(bitmap):
20  return bitmap.pixels
21
22def GetPixelColor(bitmap, x, y):
23  return bitmap.GetPixelColor(x, y)
24
25def WritePngFile(bitmap, path):
26  bitmap.WritePngFile(path)
27
28def FromRGBPixels(width, height, pixels, bpp):
29  return _bitmap.Bitmap(bpp, width, height, pixels)
30
31def FromPng(png_data):
32  return _bitmap.Bitmap.FromPng(png_data)
33
34def FromPngFile(path):
35  return _bitmap.Bitmap.FromPngFile(path)
36
37def AreEqual(bitmap1, bitmap2, tolerance, _):
38  return bitmap1.IsEqual(bitmap2, tolerance)
39
40def Diff(bitmap1, bitmap2):
41  return bitmap1.Diff(bitmap2)
42
43def GetBoundingBox(bitmap, color, tolerance):
44  return bitmap.GetBoundingBox(color, tolerance)
45
46def Crop(bitmap, left, top, width, height):
47  return bitmap.Crop(left, top, width, height)
48
49def GetColorHistogram(bitmap, ignore_color, tolerance):
50  return bitmap.ColorHistogram(ignore_color, tolerance)
51