Class: SwfConverter::Engine::Alphize

Inherits:
SwfConverter::Engine show all
Includes:
Runner
Defined in:
lib/swf_converter/engine/alphize.rb,
lib/swf_converter/engine/alphize/runner.rb,
lib/swf_converter/engine/alphize/blender.rb

Defined Under Namespace

Modules: Runner Classes: Blender, ConversionError

Constant Summary collapse

SWF_PATHS =
{}.tap do |paths|
  [:black, :white].each do |type|
    paths[type] = File.expand_path("../alphize/swfs/#{type}.swf", __FILE__)
  end
end
TEMP_NAMES =
[:negative, :alpha, :division]

Instance Attribute Summary

Attributes inherited from SwfConverter::Engine

#options, #parent

Instance Method Summary collapse

Methods included from Runner

#e, #run

Constructor Details

#initializeAlphize

Returns a new instance of Alphize.



20
21
22
# File 'lib/swf_converter/engine/alphize.rb', line 20

def initialize
  @output_images = {}
end

Instance Method Details

#convert!(swf_parent) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/swf_converter/engine/alphize.rb', line 24

def convert!(swf_parent)
  images = {
    :black => Tempfile.open('swf_converter_alphize_black.png'),
    :white => Tempfile.open('swf_converter_alphize_white.png')
  }
  begin
    write_opaque_images(swf_parent, images)
    blend(swf_parent, images)
    if swf_parent.respond_to?(:after_swf_conversion)
      swf_parent.after_swf_conversion(@output_images)
    end
  ensure
    images[:black].close!
    images[:white].close!
  end
end