Class: Hornetseye::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/hornetseye-rmagick/node.rb

Instance Method Summary collapse

Instance Method Details

#save_magick(file) ⇒ Object



74
75
76
77
# File 'lib/hornetseye-rmagick/node.rb', line 74

def save_magick( file )
  Magick::ImageList.new.push( to_magick ).write file
  self
end

#save_ubyte(file) ⇒ Object



79
80
81
# File 'lib/hornetseye-rmagick/node.rb', line 79

def save_ubyte( file )
  to_ubyte.save_magick file
end

#save_ubytergb(file) ⇒ Object



91
92
93
# File 'lib/hornetseye-rmagick/node.rb', line 91

def save_ubytergb( file )
  to_ubytergb.save_magick file
end

#save_uint(file) ⇒ Object



87
88
89
# File 'lib/hornetseye-rmagick/node.rb', line 87

def save_uint( file )
  to_uint.save_magick file
end

#save_uintrgb(file) ⇒ Object



99
100
101
# File 'lib/hornetseye-rmagick/node.rb', line 99

def save_uintrgb( file )
  to_uintrgb.save_magick file
end

#save_usint(file) ⇒ Object



83
84
85
# File 'lib/hornetseye-rmagick/node.rb', line 83

def save_usint( file )
  to_usint.save_magick file
end

#save_usintrgb(file) ⇒ Object



95
96
97
# File 'lib/hornetseye-rmagick/node.rb', line 95

def save_usintrgb( file )
  to_usintrgb.save_magick file
end

#to_magickObject



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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/hornetseye-rmagick/node.rb', line 20

def to_magick
  unless dimension == 2
    raise "Array must have two dimensions (but has #{dimension})"
  end
  case typecode
  when UBYTE
    pixel_type = Magick::CharPixel
    colourspace = 'I'
    depth = 8
  when USINT
    pixel_type = Magick::ShortPixel
    colourspace = 'I'
    depth = 16
  when UINT
    pixel_type = Magick::IntegerPixel
    colourspace = 'I'
    depth = 32
  when SFLOAT
    pixel_type = Magick::FloatPixel
    colourspace = 'I'
    depth = nil
  when DFLOAT
    pixel_type = Magick::DoublePixel
    colourspace = 'I'
    depth = nil
  when UBYTERGB
    pixel_type = Magick::CharPixel
    colourspace = 'RGB'
    depth = 8
  when USINTRGB
    pixel_type = Magick::ShortPixel
    colourspace = 'RGB'
    depth = 16
  when UINTRGB
    pixel_type = Magick::IntegerPixel
    colourspace = 'RGB'
    depth = 32
  when SFLOATRGB
    pixel_type = Magick::FloatPixel
    colourspace = 'RGB'
    depth = nil
  when DFLOATRGB
    pixel_type = Magick::DoublePixel
    colourspace = 'RGB'
    depth = nil
  else
    raise "Conversion from #{typecode} to Magick::Image not implemented"
  end
  retval = Magick::Image.new( *shape ) { self.depth = depth if depth }
  retval.import_pixels 0, 0, shape[0], shape[1], colourspace,
                       memorise.memory.export, pixel_type
  retval
end