Cairo.ImageSurface image = new Cairo.ImageSurface("image.png"); Cairo.Context cr = new Cairo.Context(image); cr.Save(); cr.Scale(0.5, 0.5); cr.SetSource(image, 0, 0); cr.Paint(); cr.Restore();
Cairo.ImageSurface image = new Cairo.ImageSurface(Cairo.Format.ARGB32, 100, 100); Cairo.Context cr = new Cairo.Context(image); cr.SetSourceRGB(0, 0, 0); cr.Rectangle(0, 0, 100, 100); cr.Fill(); cr.Save(); cr.SetSourceRGB(1, 0, 0); cr.MoveTo(50, 50); cr.ShowText("Hello, World!"); cr.Restore();This code example creates a new image, sets the source to black, fills the rectangle with black. It then saves and sets the source to red, moves to the middle of the image and shows the text "Hello, World!". Cairo is a 2D graphics library that is available on multiple platforms, with C# bindings for the .NET framework.