Class: Axon::AlphaStripper
- Inherits:
-
Object
- Object
- Axon::AlphaStripper
- Defined in:
- lib/axon/alpha_stripper.rb
Overview
Strips the Alpha Channel from an Image
Axon::AlphaStripper Removes the Alpha Channel from an Image.
Example
Instance Method Summary collapse
-
#components ⇒ Object
Gets the components in the image.
-
#gets ⇒ Object
Gets the next scanline from the image.
-
#height ⇒ Object
Gets the height of the image.
-
#initialize(source) ⇒ AlphaStripper
constructor
:call-seq: AlphaStripper.new(image_in).
-
#lineno ⇒ Object
Gets the line number of the next scanline.
-
#width ⇒ Object
Gets the width of the image.
Constructor Details
#initialize(source) ⇒ AlphaStripper
:call-seq:
AlphaStripper.new(image_in)
Removes the alpha channel from image_in.
17 18 19 |
# File 'lib/axon/alpha_stripper.rb', line 17 def initialize(source) @source = source end |
Instance Method Details
#components ⇒ Object
Gets the components in the image.
35 36 37 38 39 40 41 |
# File 'lib/axon/alpha_stripper.rb', line 35 def components case @source.components when 2 then 1 when 4 then 3 else @source.components end end |
#gets ⇒ Object
Gets the next scanline from the image.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/axon/alpha_stripper.rb', line 51 def gets sl = @source.gets return unless sl # This should probably be done in C, but not seeing alpha stripping # performance as terribly important right now. case @source.components when 2 (sl.size / 2).times{ |i| sl.slice!(1) } sl when 4 (sl.size / 4).times{ |i| sl.slice!(3) } sl else sl end end |
#height ⇒ Object
Gets the height of the image. Same as the height of the source image.
23 24 25 |
# File 'lib/axon/alpha_stripper.rb', line 23 def height @source.height end |
#lineno ⇒ Object
Gets the line number of the next scanline.
45 46 47 |
# File 'lib/axon/alpha_stripper.rb', line 45 def lineno @source.lineno end |
#width ⇒ Object
Gets the width of the image. Same as the width of the source image.
29 30 31 |
# File 'lib/axon/alpha_stripper.rb', line 29 def width @source.width end |