ImageSurface


Object Hierarchy:

Cairo.ImageSurface Cairo.ImageSurface Cairo.ImageSurface Cairo.Surface Cairo.Surface Cairo.Surface->Cairo.ImageSurface

Description:

[ CCode ( cname = "cairo_surface_t" , ref_function = "cairo_surface_reference" , type_id = "cairo_gobject_surface_get_type ()" , unref_function = "cairo_surface_destroy" ) ]
[ Compact ]
public class ImageSurface : Surface

Example: Clip regions and image surfaces:

public static int main (string[] args) {
// Create a context:
Cairo.ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 256, 256);
Cairo.Context context = new Cairo.Context (surface);

// The arc:
context.arc (128.0, 128.0, 76.8, 0, 2*Math.PI);
context.clip ();
context.new_path (); // path not consumed by clip()

// The image:
string image_path = Path.build_filename (Path.get_dirname (args[0]) , "romedalen.png");
Cairo.ImageSurface image = new Cairo.ImageSurface.from_png (image_path);
int w = image.get_width ();
int h = image.get_height ();
context.scale (256.0/w, 256.0/h);

context.set_source_surface (image, 0, 0);
context.paint ();

// Save the image:
surface.write_to_png ("img.png");

return 0;
}

valac --pkg cairo clip-image.vala

Example: Simple lines:

public static int main (string[] args) {
// Create a context:
Cairo.ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 200, 40);
Cairo.Context context = new Cairo.Context (surface);

// Draw lines:
context.set_source_rgba (1, 0, 0, 1);
context.set_line_width (1);

context.move_to (10, 10);
context.line_to (190, 10);
context.line_to (190, 20);

context.move_to (10, 20);
context.line_to (190, 20);

context.stroke ();

// Save the image:
surface.write_to_png ("img.png");

return 0;
}

valac --pkg cairo simple-lines.vala


Namespace: Cairo
Package: cairo

Content:

Creation methods:

Methods:

Inherited Members: