class Win32::Screenshot::Image
Holds the bitmap data and writes it to the disk
Constants
- FORMATS
Supported output formats
Attributes
bitmap[R]
- String
-
raw bitmap blob
height[R]
- String
-
bitmap height
width[R]
- String
-
bitmap width
Public Class Methods
new(blob, width, height)
click to toggle source
@private
# File lib/win32/screenshot/image.rb, line 18 def initialize(blob, width, height) @bitmap = blob @width = width @height = height end
Public Instance Methods
write(file_path)
click to toggle source
Writes image to the disk. @param [String] file_path writes image to the specified path. @raise [RuntimeError] when file_path already exists. @raise [RuntimeError] when file_path is not with the supported output {FORMATS} extension.
# File lib/win32/screenshot/image.rb, line 28 def write(file_path) raise "File already exists: #{file_path}!" if File.exist? file_path write! file_path end
write!(file_path)
click to toggle source
Writes image to disk, writing over existing copy if it exists.
# File lib/win32/screenshot/image.rb, line 34 def write!(file_path) ext = File.extname(file_path)[1..-1] raise "File '#{file_path}' has to have one of the following extensions: #{FORMATS.join(", ")}" unless ext && FORMATS.include?(ext.downcase) if ext.downcase == "bmp" File.open(file_path, "wb") {|io| io.write @bitmap} else image = ::MiniMagick::Image.read @bitmap image.format ext image.write file_path end end