Class: Imlib2::Image

Class | Imlib2::Image
In: | imlib2.c (CVS)
Parent: | Object

### Methods

[] []= apply apply_cmod apply_color_modifier apply_filter attach_value blend blend! blend_drawable blend_image blend_image! blur blur! border border= bypass_draw_pixel= bypass_draw_pixel? changes_on_disk clear clear_color clear_color! clip_line clone color_range copy_alpha copy_alpha_rect copy_drawable copy_rect create create_cropped create_cropped! create_cropped_scaled create_cropped_scaled! create_from_drawable create_from_ximage create_using_copied_data create_using_data crop crop! crop_scaled crop_scaled! data data! data= data_for_reading_only delete! draw_ellipse draw_line draw_oval draw_pixel draw_pixel_workaround= draw_pixel_workaround? draw_poly draw_polygon draw_rect draw_rectangle draw_text dup filename fill_color_range fill_ellipse fill_gradient fill_oval fill_poly fill_polygon fill_rect fill_rectangle filter flip_diagonal flip_diagonal! flip_horizontal flip_horizontal! flip_vertical flip_vertical! format format= get_attached_value get_border get_format gradient h has_alpha has_alpha= has_alpha? height irrelevant_alpha= irrelevant_border= irrelevant_format= load load_image load_immediately load_immediately_without_cache load_with_error_return load_without_cache new new orientate orientate! pixel pixel_cmya pixel_hlsa pixel_hsva pixel_rgba pixmap put_back_data query_pixel query_pixel_cmya query_pixel_hlsa query_pixel_hsva query_pixel_rgba remove_attached_value render_on_drawable render_on_drawable_at_angle render_on_drawable_skewed render_pixmap rotate rotate! save save_image save_with_error_return script_filter scroll_rect set_border set_changes_on_disk set_format set_has_alpha set_irrelevant_alpha set_irrelevant_border set_irrelevant_format sharpen sharpen! static_filter tile tile! tile_horizontal tile_horizontal! tile_vertical tile_vertical! w width

### Public Class methods

bypass_draw_pixel=(p1)

Are we using the buggy imlib_image_draw_pixel() work-around?

Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.

Examples:

      puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround?
      puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?

bypass_draw_pixel?()

Are we using the buggy imlib_image_draw_pixel() work-around?

Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.

Examples:

      puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround?
      puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?

create(p1, p2)

Returns a new Imlib2::Image with the specified width and height.

Examples:

      width, height = 640, 480
      image = Imlib2::Image.new width, height

      width, height = 320, 240
      image = Imlib2::Image.create width, height

create_from_drawable(...)
create_from_ximage(...)
create_using_copied_data(p1, p2, p3)

Returns a new Imlib2::Image initialized with the specified data.

Examples:

      other_image = Imlib2::Image.load 'sample_file.png'
      width, height = other_image.width, other_image.height
      data = other_image.data
      image = Imlib2::Image.create_using_copied_data width, height, data

create_using_data(p1, p2, p3)

Returns a new Imlib2::Image initialized with the specified data.

Examples:

      other_image = Imlib2::Image.load 'sample_file.png'
      width, height = other_image.width, other_image.height
      data = other_image.data_for_reading_only
      image = Imlib2::Image.create_using_data width, height, data

draw_pixel_workaround=(p1)

Are we using the buggy imlib_image_draw_pixel() work-around?

Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.

Examples:

      puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround?
      puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?

draw_pixel_workaround?()

Are we using the buggy imlib_image_draw_pixel() work-around?

Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.

Examples:

      puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround?
      puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?

load(p1)

Load an Imlib2::Image from a file (throws exceptions).

Examples:

      image = Imlib2::Image.load 'sample_file.png'

      begin
        image = Imlib2::Image.load 'sample_file.png'
      rescue Imlib2::FileError
        $stderr.puts 'Couldn't load file: ' + $!
      end

load_image(p1)

Load an Imlib2::Image from a file (no exceptions or error).

Imlib2::Image::load_image() provides access to the low-level imlib_load_image() function. You probably want to use Imlib2::Image::load() instead of Imlib2::Image::load_image().

Examples:

      image = Imlib2::Image.load_image 'sample_file.png'

load_immediately(p1)

Load an Imlib2::Image from a file (no exceptions or error).

Imlib2::Image::load_immediately() provides access to the low-level imlib_load_image_immediately() function. You probably want to use Imlib2::Image::load() instead of this function.

Examples:

      image = Imlib2::Image.load_immediately 'sample_file.png'

load_immediately_without_cache(p1)

Load an Imlib2::Image from a file (no caching, deferred loading, exceptions, or errors).

Imlib2::Image::load_immediately_without_cache() provides access to the low-level imlib_load_image_immediately_without_cache() function. You probably want to use Imlib2::Image::load() instead of this function.

Examples:

      image = Imlib2::Image.load_immediately_without_cache 'sample_file.png'

load_with_error_return(p1)

Load an Imlib2::Image from a file with a hash of the error value and the image.

Imlib2::Image::load_with_error_return() provides access to the low-level imlib_load_image_with_error_return() function. You probably want to use Imlib2::Image::load() instead of this function.

Examples:

      hash = Imlib2::Image.load_with_error_return 'sample_file.png'
      if hash['error'] == 0 # 0 is no error
        image = hash['image']
      end

load_without_cache(p1)

Load an Imlib2::Image from a file (no caching, exception, or error).

Imlib2::Image::load_without_cache() provides access to the low-level imlib_load_image_without_cache() function. You probably want to use Imlib2::Image::load() instead of this function.

Examples:

      image = Imlib2::Image.load_without_cache 'sample_file.png'

new(p1, p2)

Returns a new Imlib2::Image with the specified width and height.

Examples:

      width, height = 640, 480
      image = Imlib2::Image.new width, height

      width, height = 320, 240
      image = Imlib2::Image.create width, height

new()

Imlib2::Image constructor (currently just an empty placeholder).

### Public Instance methods

[](p1)

Get an integer value attached to an Imlib2::Image.

Examples:

      qual = image.get_attached_value('quality')
      qual = image['quality']

[]=(p1, p2)

Attach an integer value to an Imlib2::Image.

Examples:

      image.attach_value('quality', 90)
      image['quality'] = 90

apply(p1)

Apply an Imlib2::ColorModifier to the image

Examples:

      # modify the contrast of the entire image
      cmod = Imlib2::ColorModifier.new
      cmod.contrast = 1.5
      image.apply_cmod color_mod

      # adjust the gamma of the given rect
      cmod = Imlib2::ColorModifier.new
      cmod.gamma = 0.5
      rect = [10, 10, 20, 40]
      image.apply_color_modifier cmod, rect

apply_cmod(p1)

Apply an Imlib2::ColorModifier to the image

Examples:

      # modify the contrast of the entire image
      cmod = Imlib2::ColorModifier.new
      cmod.contrast = 1.5
      image.apply_cmod color_mod

      # adjust the gamma of the given rect
      cmod = Imlib2::ColorModifier.new
      cmod.gamma = 0.5
      rect = [10, 10, 20, 40]
      image.apply_color_modifier cmod, rect

apply_color_modifier(p1)

Apply an Imlib2::ColorModifier to the image

Examples:

      # modify the contrast of the entire image
      cmod = Imlib2::ColorModifier.new
      cmod.contrast = 1.5
      image.apply_cmod color_mod

      # adjust the gamma of the given rect
      cmod = Imlib2::ColorModifier.new
      cmod.gamma = 0.5
      rect = [10, 10, 20, 40]
      image.apply_color_modifier cmod, rect

apply_filter(p1)

Apply a scripted filter or a static (eg Imlib2::Filter) filter

Example:

      # apply a static filter
      filter = Imlib2::Filter.new 20
      filter.set 2, 2, Imlib2::Color::GREEN
      image.filter filter

      # apply a scripted filter
      x, y = 20, 10
      filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );"
      image.filter filter_string

attach_value(p1, p2)

Attach an integer value to an Imlib2::Image.

Examples:

      image.attach_value('quality', 90)
      image['quality'] = 90

blend(...)

Return a copy of the image with the a portion of the source image blended at the specified rectangle.

Examples:

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend source_image,
                  src_x, src_y, src_w, src_h,
                  dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend source_image, src_rect, dst_rect, merge_alpha

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend_image source_image,
                        src_x, src_y, src_w, src_h,
                        dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend_image source_image, src_rect, dst_rect, merge_alpha

blend!(...)

Blend a source image onto the image

Examples:

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend! source_image,
                  src_x, src_y, src_w, src_h,
                  dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend! source_image, src_rect, dst_rect, merge_alpha

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend_image! source_image,
                         src_x, src_y, src_w, src_h,
                         dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend_image! source_image, src_rect, dst_rect, merge_alpha

blend_drawable(...)
blend_image(...)

Return a copy of the image with the a portion of the source image blended at the specified rectangle.

Examples:

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend source_image,
                  src_x, src_y, src_w, src_h,
                  dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend source_image, src_rect, dst_rect, merge_alpha

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend_image source_image,
                        src_x, src_y, src_w, src_h,
                        dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend_image source_image, src_rect, dst_rect, merge_alpha

blend_image!(...)

Blend a source image onto the image

Examples:

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend! source_image,
                  src_x, src_y, src_w, src_h,
                  dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend! source_image, src_rect, dst_rect, merge_alpha

      src_x, src_y, src_w, src_h = 10, 10, 100, 100
      dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50
      image.blend_image! source_image,
                         src_x, src_y, src_w, src_h,
                         dst_x, dst_y, dst_w, dst_h

      src_rect = [50, 50, 5, 5]
      dst_rect = [0, 0, image.width, image.height]
      merge_alpha = false
      image.blend_image! source_image, src_rect, dst_rect, merge_alpha

blur(p1)

Return a blurred copy of an image

Examples:

      radius = 20 # radius of blur, in pixels
      new_image = old_image.blur radius

blur!(p1)

Blur an image

Examples:

      radius = 20 # radius of blur, in pixels
      image.blur! radius

border()

Get the Imlib2::Border of an Imlib2::Image

Examples:

      border = image.get_border
      border = image.border

border=(p1)

Set the Imlib2::Border of an Imlib2::Image

Examples:

      image.set_border border
      image.border = border

changes_on_disk()

Flag this image as changing on disk

Examples:

      image.changes_on_disk

clear()

Clear the contents of an image

Examples:

      image.clear

clear_color(p1)

I’m honestly not quite sure what this function does, but I wrapped it anyway.

clear_color!(p1)

I’m honestly not quite sure what this function does, but I wrapped it anyway.

clip_line(...)
clone()

Copy an Imlib2::Image

Examples:

      new_image = old_image.clone
      new_image = old_image.dup

color_range(...)

Fill a rectangle with the given Imlib2::Gradient at a given angle

Examples:

      x, y, w, h = 10, 10, image.width - 20, image.height - 20
      angle = 45.2
      image.fill_gradient gradient, x, y, w, h, angle

      rect = [5, 5, 500, 20]
      image.gradient gradient, rect, 36.8

copy_alpha(...)

Copy the alpha channel from the source image to the specified coordinates

Examples:

      image.copy_alpha source_image, 10, 10
      image.copy_alpha source_image, [10, 10]

copy_alpha_rect(...)

Copy the alpha channel from a rectangle of the source image to the specified coordinates

Examples:

      x, y, w, h = 10, 20, 100, 200
      dest_x, dest_y = 5, 10
      image.copy_alpha_rect source_image, x, y, w, h, dest_x, dest_y

      source_rect = [10, 20, 100, 200]
      dest_coords = [5, 10]
      image.copy_alpha_rect source_image, source_rect, dest_coords

      values = [10, 20, 100, 200, 5, 10]
      image.copy_alpha_rect source_image, values

copy_drawable(...)
copy_rect(...)

Copy a rectangle to the specified coordinates

Examples:

      x, y, w, h = 10, 20, 100, 200
      dest_x, dest_y = 5, 10
      image.copy_rect x, y, w, h, dest_x, dest_y

      source_rect = [10, 20, 100, 200]
      dest_coords = [5, 10]
      image.copy_rect source_rect, dest_coords

      values = [10, 20, 100, 200, 5, 10]
      image.copy_rect values

create_cropped(...)

Return a cropped copy of the image

Examples:

      x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10
      new_image = old_image.crop x, y, w, h

      rect = [10, 10, old_image.width - 10, old_image.height - 10]
      new_image = old_image.crop rect

      x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10
      new_image = old_image.create_cropped x, y, w, h

      rect = [10, 10, old_image.width - 10, old_image.height - 10]
      new_image = old_image.create_cropped rect

create_cropped!(...)

Crop an image

Examples:

      x, y, w, h = 10, 10, image.width - 10, image.height - 10
      image.crop! x, y, w, h

      rect = [10, 10, image.width - 10, image.height - 10]
      image.crop! rect

      x, y, w, h = 10, 10, image.width - 10, image.height - 10
      image.create_cropped! x, y, w, h

      rect = [10, 10, image.width - 10, image.height - 10]
      image.create_cropped! rect

create_cropped_scaled(...)

Create a cropped and scaled copy of an image

Examples:

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      new_image = old_image.crop_scaled x, y, w, h, new_w, new_h

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      new_image = old_image.crop_scaled values

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      new_image = old_image.create_crop_scaled x, y, w, h, new_w, new_h

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      new_image = old_image.create_crop_scaled values

create_cropped_scaled!(...)

Crop and scale an image

Examples:

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      image.crop_scaled! x, y, w, h, new_w, new_h

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      image.crop_scaled! values

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      image.create_crop_scaled! x, y, w, h, new_w, new_h

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      image.create_crop_scaled! values

crop(...)

Return a cropped copy of the image

Examples:

      x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10
      new_image = old_image.crop x, y, w, h

      rect = [10, 10, old_image.width - 10, old_image.height - 10]
      new_image = old_image.crop rect

      x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10
      new_image = old_image.create_cropped x, y, w, h

      rect = [10, 10, old_image.width - 10, old_image.height - 10]
      new_image = old_image.create_cropped rect

crop!(...)

Crop an image

Examples:

      x, y, w, h = 10, 10, image.width - 10, image.height - 10
      image.crop! x, y, w, h

      rect = [10, 10, image.width - 10, image.height - 10]
      image.crop! rect

      x, y, w, h = 10, 10, image.width - 10, image.height - 10
      image.create_cropped! x, y, w, h

      rect = [10, 10, image.width - 10, image.height - 10]
      image.create_cropped! rect

crop_scaled(...)

Create a cropped and scaled copy of an image

Examples:

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      new_image = old_image.crop_scaled x, y, w, h, new_w, new_h

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      new_image = old_image.crop_scaled values

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      new_image = old_image.create_crop_scaled x, y, w, h, new_w, new_h

      iw, ih = old_image.width, old_image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      new_image = old_image.create_crop_scaled values

crop_scaled!(...)

Crop and scale an image

Examples:

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      image.crop_scaled! x, y, w, h, new_w, new_h

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      image.crop_scaled! values

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      x, y, w, h = 10, 10, iw - 10, ih - 10
      image.create_crop_scaled! x, y, w, h, new_w, new_h

      iw, ih = image.width, image.height
      new_w, new_h = iw - 20, ih - 20
      values = [10, 10, iw - 10, iw - 10, new_w, new_h]
      image.create_crop_scaled! values

data()

Return a copy of an image’s raw 32-bit data.

Examples:

      raw = image.data

data!()

Return a read-only reference to an image’s raw 32-bit data.

Examples:

      RAW_DATA = image.data_for_reading_only
      RAW_DATA = image.data!

data=(p1)

Fill an image using raw 32-bit data.

Note: The new data buffer must be the same size (in bytes) as the original data buffer.

Examples:

      RAW_DATA = other_image.data!
      image.put_data RAW_DATA

      RAW_DATA = other_image.data!
      image.data = RAW_DATA

data_for_reading_only()

Return a read-only reference to an image’s raw 32-bit data.

Examples:

      RAW_DATA = image.data_for_reading_only
      RAW_DATA = image.data!

delete!(...)

Free an Imlib2::Image object, and (optionally) de-cache it as well.

Note: Any future operations on this image will raise an exception.

Examples:

      # free image
      im.delete!

      # free image, and de-cache it too
      im.delete!(true)

draw_ellipse(...)

Draw an ellipse at the specified coordinates with the given color

Examples:

      # draw an ellipse in the center of the image using the context color
      xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2
      image.draw_oval xc, yc, w, h

      # draw a violet circle in the center of the image
      rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2]
      color = Imlib2::Color::VIOLET
      image.draw_ellipse rect, color

draw_line(...)

Draw a line at the specified coordinates.

Examples:

      # draw line from 10, 10 to 20, 20 using context color
      im.draw_line 10, 10, 20, 20

      # draw magenta line from 5, 10 to 15, 20
      im.draw_line 5, 10, 15, 20, Imlib2::Color::MAGENTA

      # draw line from 10, 15 to 20, 25 using context color
      im.draw_pixel [10, 15], [20, 25]

      # draw line from 1000, 2000 to 2100, 4200 with funky color
      my_color = Imlib2::Color::CmykColor.new 100, 255, 0, 128
      im.draw_line [1000, 2000], [2100, 4200], my_color

draw_oval(...)

Draw an ellipse at the specified coordinates with the given color

Examples:

      # draw an ellipse in the center of the image using the context color
      xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2
      image.draw_oval xc, yc, w, h

      # draw a violet circle in the center of the image
      rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2]
      color = Imlib2::Color::VIOLET
      image.draw_ellipse rect, color

draw_pixel(...)

Draw a pixel at the specified coordinates.

Note: Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. To disable this behavior, see the Imlib2::Image::draw_pixel_workaround= method.

Examples:

      im.draw_pixel 10, 10                      # draw using context color
      im.draw_pixel 10, 10, Imlib2::Color::BLUE # draw blue pixel
      im.draw_pixel [10, 10], Imlib2::Color::RED # draw red pixel

draw_poly(...)

Draw an Imlib2::Polygon with the specified color

Examples:

      # create a simple blue right triangle
      triangle = Imlib2::Polygon.new [10, 10], [20, 20], [10, 20]
      image.draw_polygon triangle, Imlib2::Color::BLUE

      # create an open red square polygon
      square = Imlib2.Polygon.new [10, 10], [20, 10], [20, 20], [10, 20]
      image.draw_poly square, false, Imlib2::Color::RED

draw_polygon(...)

Draw an Imlib2::Polygon with the specified color

Examples:

      # create a simple blue right triangle
      triangle = Imlib2::Polygon.new [10, 10], [20, 20], [10, 20]
      image.draw_polygon triangle, Imlib2::Color::BLUE

      # create an open red square polygon
      square = Imlib2.Polygon.new [10, 10], [20, 10], [20, 20], [10, 20]
      image.draw_poly square, false, Imlib2::Color::RED

draw_rect(...)

Draw a rectangle outline at the specified coordinates.

Examples:

      # draw rectangle around edge of image using context color
      rect = [1, 1, im.width - 2, im.height - 2]
      im.draw_rect rect

      # draw magenta rectangle outline in top-left corner of image
      color = Imlib2::Color::MAGENTA
      im.draw_rect [0, 0], [im.width / 2, im.height / 2], color

      # draw square from 10, 10 to 30, 30 using context color
      im.draw_rect [10, 10, 20, 20]

draw_rectangle(...)

Draw a rectangle outline at the specified coordinates.

Examples:

      # draw rectangle around edge of image using context color
      rect = [1, 1, im.width - 2, im.height - 2]
      im.draw_rect rect

      # draw magenta rectangle outline in top-left corner of image
      color = Imlib2::Color::MAGENTA
      im.draw_rect [0, 0], [im.width / 2, im.height / 2], color

      # draw square from 10, 10 to 30, 30 using context color
      im.draw_rect [10, 10, 20, 20]

draw_text(...)

Draw a string with the given Imlib2::Font at the specified coordinates

Examples:

      font = Imlib2::Font.new 'helvetica/12'
      string = 'the blue crow flies at midnight'
      image.draw_text font, string, 10, 10

      # draw text in a specified color
      font = Imlib2::Font.new 'helvetica/12'
      string = 'the blue crow flies at midnight'
      color = Imlib2::Color::AQUA
      image.draw_text font, string, 10, 10, color

      # draw text in a specified direction
      font = Imlib2::Font.new 'verdana/24'
      string = 'the blue crow flies at midnight'
      color = Imlib2::Color::YELLOW
      direction = Imlib2::Direction::DOWN
      image.draw_text font, string, 10, 10, color, direction

      # draw text with return metrics
      font = Imlib2::Font.new 'arial/36'
      string = 'the blue crow flies at midnight'
      color = Imlib2::Color::PURPLE
      direction = Imlib2::Direction::LEFT
      metrics = image.draw_text font, string, 10, 10, color, direction
      ['width', 'height', 'horiz_advance', 'vert_advance'].each_index { |i, v|
        puts v << ' = ' << metrics[i]
      }

dup()

Copy an Imlib2::Image

Examples:

      new_image = old_image.clone
      new_image = old_image.dup

filename()

Return the filename of an Imlib2::Image.

Examples:

      path = image.filename

fill_color_range(...)

Fill a rectangle with the given Imlib2::Gradient at a given angle

Examples:

      x, y, w, h = 10, 10, image.width - 20, image.height - 20
      angle = 45.2
      image.fill_gradient gradient, x, y, w, h, angle

      rect = [5, 5, 500, 20]
      image.gradient gradient, rect, 36.8

fill_ellipse(...)

Fill an ellipse at the specified coordinates with the given color

Examples:

      # fill an ellipse in the center of the image using the context color
      xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2
      image.draw_oval xc, yc, w, h

      # fill a violet circle in the center of the image
      rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2]
      color = Imlib2::Color::VIOLET
      image.draw_ellipse rect, color

fill_gradient(...)

Fill a rectangle with the given Imlib2::Gradient at a given angle

Examples:

      x, y, w, h = 10, 10, image.width - 20, image.height - 20
      angle = 45.2
      image.fill_gradient gradient, x, y, w, h, angle

      rect = [5, 5, 500, 20]
      image.gradient gradient, rect, 36.8

fill_oval(...)

Fill an ellipse at the specified coordinates with the given color

Examples:

      # fill an ellipse in the center of the image using the context color
      xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2
      image.draw_oval xc, yc, w, h

      # fill a violet circle in the center of the image
      rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2]
      color = Imlib2::Color::VIOLET
      image.draw_ellipse rect, color

fill_poly(...)

Fill an Imlib2::Polygon with the specified color

Examples:

      # create an filled green diamond polygon
      square = Imlib2.Polygon.new [50, 10], [70, 30], [50, 50], [30, 30]
      image.fill_poly square, false, Imlib2::Color::GREEN

fill_polygon(...)

Fill an Imlib2::Polygon with the specified color

Examples:

      # create an filled green diamond polygon
      square = Imlib2.Polygon.new [50, 10], [70, 30], [50, 50], [30, 30]
      image.fill_poly square, false, Imlib2::Color::GREEN

fill_rect(...)

Fill a rectangle at the specified coordinates.

Examples:

      # fill image using context color
      rect = [0, 0, im.width, im.height]
      im.fill_rect rect

      # fill top-left quarter of image with green
      color = Imlib2::Color::GREEN
      im.fill_rect [0, 0], [im.width / 2, im.height / 2], color

      # fill square from 10, 10 to 30, 30 using context color
      im.fill_rect [10, 10, 20, 20]

fill_rectangle(...)

Fill a rectangle at the specified coordinates.

Examples:

      # fill image using context color
      rect = [0, 0, im.width, im.height]
      im.fill_rect rect

      # fill top-left quarter of image with green
      color = Imlib2::Color::GREEN
      im.fill_rect [0, 0], [im.width / 2, im.height / 2], color

      # fill square from 10, 10 to 30, 30 using context color
      im.fill_rect [10, 10, 20, 20]

filter(p1)

Apply a scripted filter or a static (eg Imlib2::Filter) filter

Example:

      # apply a static filter
      filter = Imlib2::Filter.new 20
      filter.set 2, 2, Imlib2::Color::GREEN
      image.filter filter

      # apply a scripted filter
      x, y = 20, 10
      filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );"
      image.filter filter_string

flip_diagonal()

Create a copy of an image flipped along it’s diagonal axis

Examples:

      new_image = old_image.flip_diagonal

flip_diagonal!()

Flip an image along it’s diagonal axis

Examples:

      image.flip_diagonal!

flip_horizontal()

Create a horizontally-flipped copy of an image

Examples:

      backwards_image = old_image.flip_horizontal

flip_horizontal!()

Flip an image horizontally

Examples:

      image.flip_horizontal!

flip_vertical()

Create a vertically-flipped copy of an image

Examples:

      upside_down_image = old_image.flip_vertical

flip_vertical!()

Flip an image vertically

Examples:

      image.flip_vertical!

format()

Get the on-disk format of an Imlib2::Image

Examples:

      format = image.get_format
      format = image.format

format=(p1)

Set the on-disk format of an Imlib2::Image

Examples:

      image.get_format 'png'
      image.format = 'png'

get_attached_value(p1)

Get an integer value attached to an Imlib2::Image.

Examples:

      qual = image.get_attached_value('quality')
      qual = image['quality']

get_border()

Get the Imlib2::Border of an Imlib2::Image

Examples:

      border = image.get_border
      border = image.border

get_format()

Get the on-disk format of an Imlib2::Image

Examples:

      format = image.get_format
      format = image.format

gradient(...)

Fill a rectangle with the given Imlib2::Gradient at a given angle

Examples:

      x, y, w, h = 10, 10, image.width - 20, image.height - 20
      angle = 45.2
      image.fill_gradient gradient, x, y, w, h, angle

      rect = [5, 5, 500, 20]
      image.gradient gradient, rect, 36.8

h()

Return the height of an Imlib2::Image.

Examples:

      h = image.height
      h = image.h

has_alpha()

Does this image have transparent or translucent regions?

Examples:

      if image.has_alpha?
        puts 'this image has alpha'
      end

has_alpha=(p1)

Set image alpha transparency.

Examples:

      image.set_has_alpha true
      image.has_alpha = true

has_alpha?()

Does this image have transparent or translucent regions?

Examples:

      if image.has_alpha?
        puts 'this image has alpha'
      end

height()

Return the height of an Imlib2::Image.

Examples:

      h = image.height
      h = image.h

irrelevant_alpha=(p1)

Set the irrelevant_alpha flag of an Imlib2::Image

Examples:

      image.set_irrelevant_alpha true
      image.irrelevant_alpha = true

irrelevant_border=(p1)

Set the irrelevant_border flag of an Imlib2::Image

Examples:

      image.set_irrelevant_border true
      image.irrelevant_border = true

irrelevant_format=(p1)

Set the irrelevant_format flag of an Imlib2::Image

Examples:

      image.set_irrelevant_format true
      image.irrelevant_format = true

orientate(p1)

Return a copy of an image rotated in 90 degree increments

Examples:

      increments = 3 # 90 * 3 degrees (eg 270 degrees)
      new_image = old_image.orientate increments

orientate!(p1)

Rotate an image in 90 degree increments

Examples:

      increments = 3 # 90 * 3 degrees (eg 270 degrees)
      image.orientate! increments

pixel(p1, p2)

Get the Imlib2::Color::RgbaColor value of the pixel at x, y

Examples:

      color = image.query_pixel 320, 240
      color = image.pixel 320, 240

pixel_cmya(p1, p2)

Get the Imlib2::Color::CmyaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_cmya 320, 240
      color = image.pixel_cmya 320, 240

pixel_hlsa(p1, p2)

Get the Imlib2::Color::HlsaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_hlsa 320, 240
      color = image.pixel_hlsa 320, 240

pixel_hsva(p1, p2)

Get the Imlib2::Color::HsvaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_hsva 320, 240
      color = image.pixel_hsva 320, 240

pixel_rgba(p1, p2)

Get the Imlib2::Color::RgbaColor value of the pixel at x, y

Examples:

      color = image.query_pixel 320, 240
      color = image.pixel 320, 240

pixmap(...)
put_back_data(p1)

Fill an image using raw 32-bit data.

Note: The new data buffer must be the same size (in bytes) as the original data buffer.

Examples:

      RAW_DATA = other_image.data!
      image.put_data RAW_DATA

      RAW_DATA = other_image.data!
      image.data = RAW_DATA

query_pixel(p1, p2)

Get the Imlib2::Color::RgbaColor value of the pixel at x, y

Examples:

      color = image.query_pixel 320, 240
      color = image.pixel 320, 240

query_pixel_cmya(p1, p2)

Get the Imlib2::Color::CmyaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_cmya 320, 240
      color = image.pixel_cmya 320, 240

query_pixel_hlsa(p1, p2)

Get the Imlib2::Color::HlsaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_hlsa 320, 240
      color = image.pixel_hlsa 320, 240

query_pixel_hsva(p1, p2)

Get the Imlib2::Color::HsvaColor value of the pixel at x, y

Examples:

      color = image.query_pixel_hsva 320, 240
      color = image.pixel_hsva 320, 240

query_pixel_rgba(p1, p2)

Get the Imlib2::Color::RgbaColor value of the pixel at x, y

Examples:

      color = image.query_pixel 320, 240
      color = image.pixel 320, 240

remove_attached_value(p1)

Remove an integer value attached to an Imlib2::Image.

Examples:

      image.remove_attached_value('quality')

render_on_drawable(...)
render_on_drawable_at_angle(...)
render_on_drawable_skewed(...)
render_pixmap(...)
rotate(p1)

Return a rotated copy of the image

Examples:

      new_image = old_image.rotate 37.2

rotate!(p1)

Rotates the image

Examples:

      image.rotate! 37.2

save(p1)

Save an Imlib2::Image to a file (throws an exception on error).

Examples:

      image.save 'output_file.png'

      filename = 'output_file.jpg'
      begin
        image.save filename
      rescue Imlib2::FileError
        $stderr.puts "Couldn't save file \"#{filename}\": " + $!
      end

save_image(p1)

Save an Imlib2::Image to a file (no exception or error).

Provides access to the low-level imlib_save_image() call. You probably want to use Imlib2::Image::save() instead.

Examples:

      image.save_image 'output_file.png'

save_with_error_return(p1)

Save an Imlib2::Image to a file (error returned as number).

Provides access to the low-level imlib_save_image_with_error_return() call. You probably want to use Imlib2::Image::save() instead.

Examples:

      error = image.save_with_error_return 'output_file.png'
      puts 'an error occurred' unless error == 0

script_filter(p1)

Apply a scripted filter

You should probably using Imlib2::Image#filter() instead, since it is polymorphic (eg, it can handle both static and scripted filters).

Example:

      x, y = 20, 10
      filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );"
      image.script_filter filter_string

scroll_rect(...)

Scroll a rectangle to the specified coordinates

Examples:

      x, y, w, h = 10, 20, 100, 200
      dest_x, dest_y = 5, 10
      image.scroll_rect x, y, w, h, dest_x, dest_y

      source_rect = [10, 20, 100, 200]
      dest_coords = [5, 10]
      image.scroll_rect source_rect, dest_coords

      values = [10, 20, 100, 200, 5, 10]
      image.scroll_rect values

set_border(p1)

Set the Imlib2::Border of an Imlib2::Image

Examples:

      image.set_border border
      image.border = border

set_changes_on_disk()

Flag this image as changing on disk

Examples:

      image.changes_on_disk

set_format(p1)

Set the on-disk format of an Imlib2::Image

Examples:

      image.get_format 'png'
      image.format = 'png'

set_has_alpha(p1)

Set image alpha transparency.

Examples:

      image.set_has_alpha true
      image.has_alpha = true

set_irrelevant_alpha(p1)

Set the irrelevant_alpha flag of an Imlib2::Image

Examples:

      image.set_irrelevant_alpha true
      image.irrelevant_alpha = true

set_irrelevant_border(p1)

Set the irrelevant_border flag of an Imlib2::Image

Examples:

      image.set_irrelevant_border true
      image.irrelevant_border = true

set_irrelevant_format(p1)

Set the irrelevant_format flag of an Imlib2::Image

Examples:

      image.set_irrelevant_format true
      image.irrelevant_format = true

sharpen(p1)

Return a sharpened copy of an image

Examples:

      radius = 15 # radius of sharpen, in pixels
      new_image = old_image.sharpen radius

sharpen!(p1)

Sharpened an image

Examples:

      radius = 15 # radius of sharpen, in pixels
      image.sharpen! radius

static_filter(p1)

Apply an Imlib2::Filter (eg a static filter)

You should probably using Imlib2::Image#filter() instead, since it is polymorphic (eg, it can handle both static and scripted filters).

Example:

      filter = Imlib2::Filter.new 20
      filter.set 2, 2, Imlib2::Color::GREEN
      image.static_filter filter

tile()

Return a copy of an image suitable for seamless tiling

Examples:

      horiz_tile = old_image.tile

tile!()

Modify an image so it is suitable for seamless tiling

Examples:

      image.tile!

tile_horizontal()

Return a copy of an image suitable for seamless horizontal tiling

Examples:

      horiz_tile = old_image.tile_horizontal

tile_horizontal!()

Modify an image so it is suitable for seamless horizontal tiling

Examples:

      image.tile_horizontal!

tile_vertical()

Return a copy of an image suitable for seamless vertical tiling

Examples:

      vert_tile = old_image.tile_vertical

tile_vertical!()

Modify an image so it is suitable for seamless vertical tiling

Examples:

      image.tile_vertical!

w()

Return the width of an Imlib2::Image.

Examples:

      w = image.width
      w = image.w

width()

Return the width of an Imlib2::Image.

Examples:

      w = image.width
      w = image.w

[Validate]