CreateSimilar() public method

public CreateSimilar ( Cairo content, int width, int height ) : Cairo.Surface
content Cairo
width int
height int
return Cairo.Surface
コード例 #1
0
        public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds)
        {
            Cairo.Surface similar = CairoUtils.CreateSurface(w.GdkWindow);
            Bounds  = bounds;
            Surface = similar.CreateSimilar(Content.ColorAlpha, Bounds.Width, Bounds.Height);
            Context ctx = new Context(Surface);

            ctx.Matrix = info.Fill(Bounds);
            Pattern p = new SurfacePattern(info.Surface);

            ctx.Source = p;
            ctx.Paint();
            ((IDisposable)ctx).Dispose();
            p.Destroy();
        }
コード例 #2
0
		public virtual void EnsureSurfaceModel (Surface reference)
		{
			if (disposed)
				return;
			if (reference == null)
				throw new ArgumentNullException ("Reference Surface", "Reference Surface may not be null");
			
			bool hadInternal = HasInternal;
			Surface last = null;
			if (hadInternal)
				last = Internal;
			
			// we dont need to copy to a model we are already on
			if (hadInternal && reference.SurfaceType == Internal.SurfaceType)
				return;
			
			Internal = reference.CreateSimilar (Cairo.Content.ColorAlpha, Width, Height);
			
			if (hadInternal) {
				using (Cairo.Context cr = new Cairo.Context (Internal)) {
					last.Show (cr, 0, 0);
					(cr.Target as IDisposable).Dispose ();
				}
				if (context != null) {
					(context as IDisposable).Dispose ();
					context = null;
				}
				(last as IDisposable).Dispose ();
				last.Destroy ();
			}
		}