Class: Gmagick
- Inherits:
-
Prawn::Images::Image
- Object
- Prawn::Images::Image
- Gmagick
- Defined in:
- lib/prawn/gmagick.rb
Instance Attribute Summary collapse
-
#bits ⇒ Object
Returns the value of attribute bits.
-
#gimage ⇒ Object
Returns the value of attribute gimage.
-
#height ⇒ Object
Returns the value of attribute height.
-
#scaled_height ⇒ Object
Returns the value of attribute scaled_height.
-
#scaled_width ⇒ Object
Returns the value of attribute scaled_width.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #build_pdf_object(document) ⇒ Object
-
#initialize(image_blob) ⇒ Gmagick
constructor
A new instance of Gmagick.
Constructor Details
Instance Attribute Details
#bits ⇒ Object
Returns the value of attribute bits.
5 6 7 |
# File 'lib/prawn/gmagick.rb', line 5 def bits @bits end |
#gimage ⇒ Object
Returns the value of attribute gimage.
7 8 9 |
# File 'lib/prawn/gmagick.rb', line 7 def gimage @gimage end |
#height ⇒ Object
Returns the value of attribute height.
5 6 7 |
# File 'lib/prawn/gmagick.rb', line 5 def height @height end |
#scaled_height ⇒ Object
Returns the value of attribute scaled_height.
6 7 8 |
# File 'lib/prawn/gmagick.rb', line 6 def scaled_height @scaled_height end |
#scaled_width ⇒ Object
Returns the value of attribute scaled_width.
6 7 8 |
# File 'lib/prawn/gmagick.rb', line 6 def scaled_width @scaled_width end |
#width ⇒ Object
Returns the value of attribute width.
5 6 7 |
# File 'lib/prawn/gmagick.rb', line 5 def width @width end |
Class Method Details
Instance Method Details
#build_pdf_object(document) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/prawn/gmagick.rb', line 20 def build_pdf_object(document) obj = document.ref!( Type: :XObject, Subtype: :Image, ColorSpace: gimage.colorspace, Height: height, Width: width, BitsPerComponent: bits ) obj << gimage.unpack obj.stream.filters << { FlateDecode: nil } alpha_mask = self.gimage.alpha_unpack if alpha_mask.unpack("C*").uniq.length > 1 smask_obj = document.ref!( :Type => :XObject, :Subtype => :Image, :Height => height, :Width => width, :BitsPerComponent => bits, :ColorSpace => :DeviceGray, :Decode => [0, 1] ) smask_obj.stream << alpha_mask smask_obj.stream.filters << { FlateDecode: nil } obj.data[:SMask] = smask_obj end obj end |