Class: EhbGameLib::Window::GlReadPixelsImage
- Inherits:
-
Object
- Object
- EhbGameLib::Window::GlReadPixelsImage
- Defined in:
- lib/ehb_game_lib/window/gl_read_pixels_image.rb
Constant Summary collapse
- DEPTH =
4
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(x, y, width, height) ⇒ GlReadPixelsImage
constructor
A new instance of GlReadPixelsImage.
- #to_blob ⇒ Object
Constructor Details
#initialize(x, y, width, height) ⇒ GlReadPixelsImage
Returns a new instance of GlReadPixelsImage.
10 11 12 13 14 15 16 17 |
# File 'lib/ehb_game_lib/window/gl_read_pixels_image.rb', line 10 def initialize(x, y, width, height) @columns = width @rows = height Gosu.flush Gosu.gl do @blob = ::Gl.glReadPixels(x, y, width, height, Gl::GL_RGBA, Gl::GL_UNSIGNED_BYTE) end end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/ehb_game_lib/window/gl_read_pixels_image.rb', line 6 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/ehb_game_lib/window/gl_read_pixels_image.rb', line 6 def rows @rows end |
Instance Method Details
#to_blob ⇒ Object
19 20 21 |
# File 'lib/ehb_game_lib/window/gl_read_pixels_image.rb', line 19 def to_blob @blob.force_encoding('binary').scan(/.{#{columns * 4}}/m).reverse.join end |