Class: Iup::Image

Inherits:
ImageWidget show all
Defined in:
lib/wrapped/image.rb

Overview

Image made from greyscale values. For example:

 pixmap_x = [
  1,2,3,3,3,3,3,3,3,2,1, 
  2,1,2,3,3,3,3,3,2,1,2, 
  3,2,1,2,3,3,3,2,1,2,3, 
  3,3,2,1,2,3,2,1,2,3,3, 
  3,3,3,2,1,2,1,2,3,3,3, 
  3,3,3,3,2,1,2,3,3,3,3, 
  3,3,3,2,1,2,1,2,3,3,3, 
  3,3,2,1,2,3,2,1,2,3,3, 
  3,2,1,2,3,3,3,2,1,2,3, 
  2,1,2,3,3,3,3,3,2,1,2, 
  1,2,3,3,3,3,3,3,3,2,1
]

img = Image.new 11, 11, pixmap_x

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods inherited from ImageWidget

#color, #colour, #save

Methods inherited from Widget

#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb

Methods included from AttributeBuilders

#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly

Methods included from CallbackSetter

#define_callback

Constructor Details

#initialize(width, height, pixels, &block) ⇒ Image

Constructor creates an image from raw pixels, using 1-value per pixel.

width

width of image in pixels

height

height of image in pixels

pixels

an array of pixel values

block

an optional block to set attributes



81
82
83
84
85
86
# File 'lib/wrapped/image.rb', line 81

def initialize width, height, pixels, &block
  @handle = IupLib.IupImage width, height, IupLib.pointer_from_chars(pixels)

  # run any provided block on instance, to set up further attributes
  self.instance_eval &block if block_given?
end