Class: Hornetseye::Frame_

Inherits:
Object show all
Defined in:
docs/hornetseye-frame/lib/hornetseye-frame/frame.rb,
docs/hornetseye-xorg/lib/hornetseye-xorg/frame.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height, options = {}) ⇒ Frame_

Returns a new instance of Frame_.



93
94
95
96
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 93

def initialize(width, height, options = {})
  @width, @height = width, height
  @memory = options[:memory] || Malloc.align(self.class.storage_size(width, height), 16)
end

Class Attribute Details

.typecodeObject

Returns the value of attribute typecode.



24
25
26
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 24

def typecode
  @typecode
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



89
90
91
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 89

def height
  @height
end

#memoryObject (readonly)

Returns the value of attribute memory.



91
92
93
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 91

def memory
  @memory
end

#widthObject (readonly)

Returns the value of attribute width.



87
88
89
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 87

def width
  @width
end

Class Method Details

.==(other) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 65

def ==( other )
  if other.is_a? Class
    if other < Frame_
      other.typecode == typecode
    else
      false
    end
  else
    false
  end
end

.eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 81

def eql?( other )
  self == other
end

.hashObject



77
78
79
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 77

def hash
  [:Frame_, typecode].hash
end

.inspectObject



26
27
28
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 26

def inspect
  to_s
end

.rgb?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 61

def rgb?
  true
end

.storage_size(width, height) ⇒ Object



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
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 34

def storage_size(width, height)
  case typecode
  when BGR
    width * height * 3
  when BGRA
    width * height * 4
  when UYVY
    widtha = ( width + 3 ) & ~0x3
    widtha * height * 2
  when YUY2
    widtha = ( width + 3 ) & ~0x3
    widtha * height * 2
  when YV12
    width2  = ( width  + 1 ).div 2
    height2 = ( height + 1 ).div 2
    widtha  = ( width  + 7 ) & ~0x7
    width2a = ( width2 + 7 ) & ~0x7
    widtha * height + 2 * width2a * height2
  when I420
    ( width * height * 3 ).div 2
  when MJPG
    width * height * 2
  else
    raise "Memory size of #{inspect} is not known"
  end
end

.to_sObject



30
31
32
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 30

def to_s
  "Frame(#{typecode})"
end

Instance Method Details

#dupObject



102
103
104
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 102

def dup
  self.class.new @width, @height, :memory => @memory.dup
end

#inspectObject



98
99
100
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 98

def inspect
  "#{self.class.inspect}(#{@width},#{@height},#{ "0x%08x" % @memory.object_id })"
end

#memoriseObject



114
115
116
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 114

def memorise
  self
end

#orig_to_typeObject



126
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 126

alias_method :orig_to_type, :to_type

#rgb?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 122

def rgb?
  self.class.rgb?
end

#shapeObject



110
111
112
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 110

def shape
  [@width, @height]
end

#show(*args) ⇒ Object



22
23
24
# File 'docs/hornetseye-xorg/lib/hornetseye-xorg/frame.rb', line 22

def show( *args )
  X11Display.show self, *args
end

#storage_sizeObject



118
119
120
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 118

def storage_size
  self.class.storage_size @width, @height
end

#to_type(target) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 128

def to_type( target )
  if target.is_a? Class
    if ( target < INT_ and target != UBYTE ) or target < FLOAT_ or
      target < COMPLEX_
      to_type( UBYTE ).to_type target
    elsif target < RGB_ and target != UBYTERGB
      to_type( UBYTERGB ).to_type target
    else
      orig_to_type target
    end
  else
    orig_to_type target
  end
end

#typecodeObject



106
107
108
# File 'docs/hornetseye-frame/lib/hornetseye-frame/frame.rb', line 106

def typecode
  self.class.typecode
end