class CooCoo::DataSources::Xournal::Image
Attributes
bottom[RW]
data[RW]
left[RW]
raw_data[RW]
right[RW]
top[RW]
Public Class Methods
new(left, top, right, bottom, data = nil)
click to toggle source
# 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
Public Instance Methods
data=(data)
click to toggle source
# File lib/coo-coo/data_sources/xournal/document.rb, line 329 def data=(data) case data when String then data = Base64.decode64(data) @data = decode_image(data) rescue nil @raw_data = data when ChunkyPNG::Image then @data = data @raw_data = nil when nil then @data = @raw_data = nil else @raw_data = data end end
data_string()
click to toggle source
# File lib/coo-coo/data_sources/xournal/document.rb, line 367 def data_string Base64.encode64(raw_data) end
decode_image(data)
click to toggle source
# File lib/coo-coo/data_sources/xournal/document.rb, line 363 def decode_image(data) ChunkyPNG::Image.from_string(data) end
height()
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# File lib/coo-coo/data_sources/xournal/document.rb, line 355 def width (right - left).to_i end