tools/swf2lwf/lib/chunky_png/canvas/operations.rb
# Crops an image, given the coordinates and size of the image that needs to be cut out.
#
# This will change the size and content of the current canvas. Use {#crop} if you want to 
# have a new canvas returned instead, leaving the current canvas intact.
#
# @param [Integer] x The x-coordinate of the top left corner of the image to be cropped.
# @param [Integer] y The y-coordinate of the top left corner of the image to be cropped.
# @param [Integer] crop_width The width of the image to be cropped.
# @param [Integer] crop_height The height of the image to be cropped.
# @return [ChunkyPNG::Canvas] Returns itself, but cropped. 
# @raise [ChunkyPNG::OutOfBounds] when the crop dimensions plus the given coordinates 
#     are bigger then the original image.      
Crops an image, given the coordinates and size of the image that needs to be cut out.
This will change the size and content of the current canvas. Use {#crop} if you want to
have a new canvas returned instead, leaving the current canvas intact.
Crops an image given the coordinates and size of the image that needs to be cut out . This will change the size and content of the current canvas . Use { #crop } if you want to have a new canvas returned instead leaving the current canvas intact .
def crop!(x, y, crop_width, crop_height)
        raise ChunkyPNG::OutOfBounds, "Image width is too small!" if crop_width + x > width
        raise ChunkyPNG::OutOfBounds, "Image width is too small!" if crop_height + y > height
        new_pixels = []
        for cy in 0...crop_height do
          new_pixels += pixels.slice((cy + y) * width + x, crop_width)
        end
        replace_canvas!(crop_width, crop_height, new_pixels)
      end
def crop! ( x , y , crop_width , crop_height ) raise ChunkyPNG :: OutOfBounds , "Image width is too small!" if crop_width + x > width raise ChunkyPNG :: OutOfBounds , "Image width is too small!" if crop_height + y > height new_pixels = [ ] for cy in 0 ... crop_height do new_pixels += pixels . slice ( ( cy + y ) * width + x , crop_width ) end replace_canvas! ( crop_width , crop_height , new_pixels ) end
Crops an image, given the coordinates and size of the image that needs to be cut out.
Crops an image given the coordinates and size of the image that needs to be cut out .
Returns itself, but cropped.
Returns itself but cropped .
ChunkyPNG::Canvas
[ChunkyPNG::OutOfBounds] when the crop dimensions plus the given coordinates are bigger then the original image.
[ ChunkyPNG :: OutOfBounds ] when the crop dimensions plus the given coordinates are bigger then the original image .
x
y
crop_width
crop_height
crop_height The height of the image to be cropped.
crop_height The height of the image to be cropped .