Class: CooCoo::DataSources::Xournal::Image
- Defined in:
- lib/coo-coo/data_sources/xournal/document.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#data ⇒ Object
Returns the value of attribute data.
-
#left ⇒ Object
Returns the value of attribute left.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
Instance Method Summary collapse
- #data_string ⇒ Object
- #decode_image(data) ⇒ Object
- #height ⇒ Object
-
#initialize(left, top, right, bottom, data = nil) ⇒ Image
constructor
A new instance of Image.
- #sized_data(zx = 1.0, zy = 1.0) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(left, top, right, bottom, data = nil) ⇒ Image
Returns a new instance of Image.
321 322 323 324 325 326 327 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 321 def initialize(left, top, right, bottom, data = nil) @left = left.to_f @top = top.to_f @right = right.to_f @bottom = bottom.to_f self.data = data end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
318 319 320 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 318 def bottom @bottom end |
#data ⇒ Object
Returns the value of attribute data.
319 320 321 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 319 def data @data end |
#left ⇒ Object
Returns the value of attribute left.
318 319 320 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 318 def left @left end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
319 320 321 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 319 def raw_data @raw_data end |
#right ⇒ Object
Returns the value of attribute right.
318 319 320 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 318 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
318 319 320 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 318 def top @top end |
Instance Method Details
#data_string ⇒ Object
367 368 369 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 367 def data_string Base64.encode64(raw_data) end |
#decode_image(data) ⇒ Object
363 364 365 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 363 def decode_image(data) ChunkyPNG::Image.from_string(data) end |
#height ⇒ Object
359 360 361 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 359 def height (bottom - top).to_i end |
#sized_data(zx = 1.0, zy = 1.0) ⇒ Object
347 348 349 350 351 352 353 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 347 def sized_data(zx = 1.0, zy = 1.0) if zx == 1.0 && zy == 1.0 @sized_data ||= @data.resample_bilinear(width, height) else @data.resample_bilinear((width * zx).to_i, (height * zy).to_i) end end |
#width ⇒ Object
355 356 357 |
# File 'lib/coo-coo/data_sources/xournal/document.rb', line 355 def width (right - left).to_i end |