-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_processor.rb
35 lines (33 loc) · 1.25 KB
/
image_processor.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# image_processor.rb
# Thumber
#
# Created by Ben Sandofsky on 4/15/09.
# Copyright (c) 2009 Ben Sandofsky. All rights reserved.
#
class ImageProcessor
# movie, frame_number, time_scale, width, height, at
attr_accessor :options
def initialize(options = {})
@options = options
end
def main
puts "Processing: #{@options[:frame_number]}"
time = QTMakeTime(@options[:frame_number].longLongValue, @options[:time_scale].longValue)
size = NSSize.new
size.width = options[:width].floatValue
size.height = options[:height].floatValue
value = NSValue.valueWithSize(size)
attributes = {"QTMovieFrameImageSize" => value}
rect = NSRect.new
rect.size = size
image = @options[:movie].frameImageAtTime time #, :withAttributes => NSDictionary.dictionaryWithDictionary(attributes), :error => nil
# We would rather run this than resize in a seperate operation,
# but we get errors if we call using the withAttributes.
# image.drawAtPoint @options[:at], :fromRect => rect, :operation => NSCompositeSourceOver, :fraction => 1.0
rect.origin = @options[:at]
fromRect = NSRect.new
fromRect.size = image.size
image.drawInRect rect, :fromRect => fromRect, :operation => NSCompositeSourceOver, :fraction => 1.0
end
end