Class: Magick::Image
- Inherits:
-
Object
- Object
- Magick::Image
- Defined in:
- lib/CocoaMagick.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#image ⇒ Object
Returns the value of attribute image.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(width, height, fill = nil) ⇒ Image
constructor
A new instance of Image.
- #write(filename) ⇒ Object
Constructor Details
#initialize(width, height, fill = nil) ⇒ Image
Returns a new instance of Image.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/CocoaMagick.rb', line 241 def initialize(width, height, fill=nil) log "Image.initialize #{width} #{height} #{fill}" @width = width @height = height @image = OSX::NSImage.alloc.initWithSize([width,height]) @image.lockFocus if fill == nil OSX::NSColor.blackColor.set OSX::NSRectFill([0,0,width,height]) elsif fill.class == Magick::GradientFill gradient = fill.image gradient.drawInRect_fromRect_operation_fraction([0,0,width,height], [0,0,gradient.size.width,gradient.size.height], OSX::NSCompositeCopy, 1.0) else fill.drawInRect_fromRect_operation_fraction([0,0,width,height], [0,0,fill.size.width,fill.size.height], OSX::NSCompositeCopy, 1.0) end $width = width $height = height self end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
240 241 242 |
# File 'lib/CocoaMagick.rb', line 240 def height @height end |
#image ⇒ Object
Returns the value of attribute image.
240 241 242 |
# File 'lib/CocoaMagick.rb', line 240 def image @image end |
#width ⇒ Object
Returns the value of attribute width.
240 241 242 |
# File 'lib/CocoaMagick.rb', line 240 def width @width end |
Class Method Details
Instance Method Details
#write(filename) ⇒ Object
262 263 264 265 266 267 |
# File 'lib/CocoaMagick.rb', line 262 def write(filename) log "Image.write #{filename}" @image.unlockFocus @image.writePNG(filename) self end |