Class: AdbSdkLib::RawImage
- Inherits:
-
Object
- Object
- AdbSdkLib::RawImage
- Defined in:
- lib/adb_sdklib/raw_image.rb
Overview
Data representing an image taken from a device frame buffer.
This is a wrapper of com.android.ddmlib.RawImage
Instance Method Summary collapse
-
#argb(index) ⇒ Integer
Returns ARGB value of a pixel.
-
#argb_at(x, y) ⇒ Integer
Returns ARGB value of a pixel.
-
#bpp ⇒ Integer
Returns image’s bpp.
-
#each_pixel {|pixel| ... } ⇒ Enumerator, self
Calls block once for each pixel in data, passing that device as a parameter.
-
#height ⇒ Integer
Returns image’s height.
-
#initialize(image) ⇒ RawImage
constructor
A new instance of RawImage.
-
#pixel(x, y) ⇒ AdbSdkLib::Pixel
Returns pixel content.
-
#point_to_index(x, y) ⇒ Integer
Returns pixel index for a given position.
-
#rotated ⇒ RawImage
Returns a rotated version of the image The image is rotated counter-clockwise.
-
#width ⇒ Integer
Returns image’s width.
Constructor Details
#initialize(image) ⇒ RawImage
Returns a new instance of RawImage.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/adb_sdklib/raw_image.rb', line 26 def initialize(image) unless image.instance_of?(Rjb::Rjb_JavaProxy) && image._classname == 'com.android.ddmlib.RawImage' raise TypeError, "Parameter is not com.android.ddmlib.RawImage class" end class << image def call_java_method(method_name, *args) rjb_method_missing(method_name, *args) rescue => e raise SdkLibError.new(e., e.class.to_s, self._classname, method_name) end alias_method :rjb_method_missing, :method_missing alias_method :method_missing, :call_java_method end @image = image end |
Instance Method Details
#argb(index) ⇒ Integer
Returns ARGB value of a pixel
53 54 55 |
# File 'lib/adb_sdklib/raw_image.rb', line 53 def argb(index) @image.getARGB(index) end |
#argb_at(x, y) ⇒ Integer
Returns ARGB value of a pixel
60 61 62 |
# File 'lib/adb_sdklib/raw_image.rb', line 60 def argb_at(x,y) @image.getARGB(point_to_index(x,y)) end |
#bpp ⇒ Integer
Returns image’s bpp
101 102 103 |
# File 'lib/adb_sdklib/raw_image.rb', line 101 def bpp() @image.bpp end |
#each_pixel {|pixel| ... } ⇒ Enumerator, self
Calls block once for each pixel in data, passing that device as a parameter. If no block is given, an enumerator is returned instead.
77 78 79 80 81 82 83 84 85 |
# File 'lib/adb_sdklib/raw_image.rb', line 77 def each_pixel() return to_enum :each_pixel unless block_given? @image.height.times do |y| @image.width.times do |x| yield pixel(x,y) end end self end |
#height ⇒ Integer
Returns image’s height
95 96 97 |
# File 'lib/adb_sdklib/raw_image.rb', line 95 def height() @image.height end |
#pixel(x, y) ⇒ AdbSdkLib::Pixel
Returns pixel content
67 68 69 |
# File 'lib/adb_sdklib/raw_image.rb', line 67 def pixel(x,y) Pixel.new(x,y,@image.getARGB(point_to_index(x,y))) end |
#point_to_index(x, y) ⇒ Integer
Returns pixel index for a given position
108 109 110 |
# File 'lib/adb_sdklib/raw_image.rb', line 108 def point_to_index(x,y) return (x*(bpp >> 3))+(y*((bpp >> 3)*(width))) end |
#rotated ⇒ RawImage
Returns a rotated version of the image The image is rotated counter-clockwise.
46 47 48 |
# File 'lib/adb_sdklib/raw_image.rb', line 46 def rotated RawImage.new(@image.getRotated()) end |
#width ⇒ Integer
Returns image’s width
89 90 91 |
# File 'lib/adb_sdklib/raw_image.rb', line 89 def width() @image.width end |