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?
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?
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
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
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
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?
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 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 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 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 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 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 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'
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
Get an integer value attached to an Imlib2::Image.
Examples:
qual = image.get_attached_value('quality') qual = image['quality']
Attach an integer value to an Imlib2::Image.
Examples:
image.attach_value('quality', 90) image['quality'] = 90
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 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 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 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 an integer value to an Imlib2::Image.
Examples:
image.attach_value('quality', 90) image['quality'] = 90
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 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
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 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
Return a blurred copy of an image
Examples:
radius = 20 # radius of blur, in pixels new_image = old_image.blur radius
Get the Imlib2::Border of an Imlib2::Image
Examples:
border = image.get_border border = image.border
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 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 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 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
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 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 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 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
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 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 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 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
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!
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
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!
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 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 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 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 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 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 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 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 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 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] }
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 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 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 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 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 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 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 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]
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
Create a copy of an image flipped along it’s diagonal axis
Examples:
new_image = old_image.flip_diagonal
Create a horizontally-flipped copy of an image
Examples:
backwards_image = old_image.flip_horizontal
Get the on-disk format of an Imlib2::Image
Examples:
format = image.get_format format = image.format
Get an integer value attached to an Imlib2::Image.
Examples:
qual = image.get_attached_value('quality') qual = image['quality']
Get the Imlib2::Border of an Imlib2::Image
Examples:
border = image.get_border border = image.border
Get the on-disk format of an Imlib2::Image
Examples:
format = image.get_format format = image.format
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
Does this image have transparent or translucent regions?
Examples:
if image.has_alpha? puts 'this image has alpha' end
Does this image have transparent or translucent regions?
Examples:
if image.has_alpha? puts 'this image has alpha' end
Set the irrelevant_alpha flag of an Imlib2::Image
Examples:
image.set_irrelevant_alpha true image.irrelevant_alpha = true
Set the irrelevant_border flag of an Imlib2::Image
Examples:
image.set_irrelevant_border true image.irrelevant_border = true
Set the irrelevant_format flag of an Imlib2::Image
Examples:
image.set_irrelevant_format true image.irrelevant_format = true
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
Rotate an image in 90 degree increments
Examples:
increments = 3 # 90 * 3 degrees (eg 270 degrees) image.orientate! increments
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
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
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
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
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
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
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
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
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
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
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 an integer value attached to an Imlib2::Image.
Examples:
image.remove_attached_value('quality')
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 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 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
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 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 the irrelevant_alpha flag of an Imlib2::Image
Examples:
image.set_irrelevant_alpha true image.irrelevant_alpha = true
Set the irrelevant_border flag of an Imlib2::Image
Examples:
image.set_irrelevant_border true image.irrelevant_border = true
Set the irrelevant_format flag of an Imlib2::Image
Examples:
image.set_irrelevant_format true image.irrelevant_format = true
Return a sharpened copy of an image
Examples:
radius = 15 # radius of sharpen, in pixels new_image = old_image.sharpen radius
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
Return a copy of an image suitable for seamless horizontal tiling
Examples:
horiz_tile = old_image.tile_horizontal
Return a copy of an image suitable for seamless vertical tiling
Examples:
vert_tile = old_image.tile_vertical