module ChunkyPNG::RMagick

def export(canvas)

Returns:
  • (Magick::Image) - The RMagick image constructed from the Canvas instance.

Parameters:
  • canvas (ChunkyPNG::Canvas) -- The canvas to export.
def export(canvas)
  image = Magick::Image.new(canvas.width, canvas.height)
  image.import_pixels(0, 0, canvas.width, canvas.height, "RGBA", canvas.pixels.pack("N*"))
  image
end

def import(image)

Returns:
  • (ChunkyPNG::Canvas) - The canvas, constructed from the RMagick image.

Parameters:
  • image (Magick::Image) -- The image to import
def import(image)
  pixels = image.export_pixels_to_str(0, 0, image.columns, image.rows, "RGBA")
  ChunkyPNG::Canvas.from_rgba_stream(image.columns, image.rows, pixels)
end