public bool OnExpose(Context ctx, Gdk.Rectangle allocation) { fraction = Math.Min(fraction, 1.0); ctx.Operator = Operator.Source; Matrix em = end_buffer.Fill(allocation); em.Translate(Math.Round(allocation.Width - allocation.Width * fraction), 0); ctx.Matrix = em; SurfacePattern sur = new SurfacePattern(end_buffer.Surface); sur.Filter = Filter.Fast; ctx.Source = sur; ctx.Paint(); sur.Destroy(); ctx.Operator = Operator.Over; SurfacePattern p = new SurfacePattern(begin_buffer.Surface); Matrix m = begin_buffer.Fill(allocation); m.Translate(Math.Round(-allocation.Width * fraction), 0); ctx.Matrix = m; p.Filter = Filter.Fast; ctx.Source = p; ctx.Paint(); p.Destroy(); return(fraction < 1.0); }
public ImageInfo (ImageInfo info, Gdk.Rectangle allocation) { #if false Surface = new ImageSurface (Format.RGB24, allocation.Width, allocation.Height); Context ctx = new Context (Surface); #else Console.WriteLine ("source status = {0}", info.Surface.Status); Surface = info.Surface.CreateSimilar (Content.Color, allocation.Width, allocation.Height); System.Console.WriteLine ("status = {1} pointer = {0}", Surface.Handle.ToString (), Surface.Status); Context ctx = new Context (Surface); #endif Bounds = allocation; ctx.Matrix = info.Fill (allocation); Pattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); }
public bool OnExpose(Context ctx, Gdk.Rectangle allocation) { ctx.Operator = Operator.Source; SurfacePattern p = new SurfacePattern(begin_buffer.Surface); ctx.Matrix = begin_buffer.Fill(allocation); p.Filter = Filter.Fast; ctx.Source = p; ctx.Paint(); ctx.Operator = Operator.Over; ctx.Matrix = end_buffer.Fill(allocation); SurfacePattern sur = new SurfacePattern(end_buffer.Surface); sur.Filter = Filter.Fast; ctx.Source = sur; Pattern mask = CreateMask(allocation, fraction); ctx.Mask(mask); mask.Destroy(); p.Destroy(); sur.Destroy(); return(fraction < 1.0); }
public bool Convert (FilterRequest req) { string source = req.Current.LocalPath; Uri dest = req.TempUri (Path.GetExtension (source)); using (ImageFile img = ImageFile.Create (source)) { using (Pixbuf pixbuf = img.Load ()) { using (ImageInfo info = new ImageInfo (pixbuf)) { MemorySurface surface = new MemorySurface (Format.Argb32, pixbuf.Width, pixbuf.Height); Context ctx = new Context (surface); ctx.Matrix = info.Fill (info.Bounds, angle); Pattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); using (Pixbuf result = CairoUtils.CreatePixbuf (surface)) { using (Stream output = File.OpenWrite (dest.LocalPath)) { img.Save (result, output); } } surface.Flush (); info.Dispose (); req.Current = dest; return true; } } } }
public ImageInfo(ImageInfo info, Gdk.Rectangle allocation) { #if false Surface = new ImageSurface(Format.RGB24, allocation.Width, allocation.Height); Context ctx = new Context(Surface); #else Console.WriteLine("source status = {0}", info.Surface.Status); Surface = info.Surface.CreateSimilar(Content.Color, allocation.Width, allocation.Height); System.Console.WriteLine("status = {1} pointer = {0}", Surface.Handle.ToString(), Surface.Status); Context ctx = new Context(Surface); #endif Bounds = allocation; ctx.Matrix = info.Fill(allocation); Pattern p = new SurfacePattern(info.Surface); ctx.Source = p; ctx.Paint(); ((IDisposable)ctx).Dispose(); p.Destroy(); }
public bool OnExpose(Context ctx, Gdk.Rectangle allocation) { if (frames == 0) { start = DateTime.UtcNow; } frames++; TimeSpan elapsed = DateTime.UtcNow - start; double fraction = elapsed.Ticks / (double)duration.Ticks; double opacity = Math.Sin(Math.Min(fraction, 1.0) * Math.PI * 0.5); ctx.Operator = Operator.Source; SurfacePattern p = new SurfacePattern(begin_buffer.Surface); ctx.Matrix = begin_buffer.Fill(allocation); p.Filter = Filter.Fast; ctx.Source = p; ctx.Paint(); ctx.Operator = Operator.Over; ctx.Matrix = end_buffer.Fill(allocation); SurfacePattern sur = new SurfacePattern(end_buffer.Surface); #if MONO_1_2_5 Pattern black = new SolidPattern(new Cairo.Color(0.0, 0.0, 0.0, opacity)); #else Pattern black = new SolidPattern(new Cairo.Color(0.0, 0.0, 0.0, opacity), true); #endif //ctx.Source = black; //ctx.Fill (); sur.Filter = Filter.Fast; ctx.Source = sur; ctx.Mask(black); //ctx.Paint (); ctx.Matrix = new Matrix(); ctx.MoveTo(allocation.Width / 2.0, allocation.Height / 2.0); ctx.Source = new SolidPattern(1.0, 0, 0); #if debug ctx.ShowText(String.Format("{0} {1} {2} {3} {4} {5} {6} {7}", frames, sur.Status, p.Status, opacity, fraction, elapsed, start, DateTime.UtcNow)); #endif sur.Destroy(); p.Destroy(); return(fraction < 1.0); }
private void OnExpose(Context ctx, Region region) { SetClip(ctx, region); if (Transition != null) { bool done = false; foreach (Gdk.Rectangle area in GetRectangles(region)) { BlockProcessor proc = new BlockProcessor(area, block_size); Gdk.Rectangle subarea; while (proc.Step(out subarea)) { ctx.Save(); SetClip(ctx, subarea); done = !Transition.OnExpose(ctx, Allocation); ctx.Restore(); } } if (done) { System.Console.WriteLine("frames = {0}", Transition.Frames); Transition = null; } } else if (effect != null) { foreach (Gdk.Rectangle area in GetRectangles(region)) { BlockProcessor proc = new BlockProcessor(area, block_size); Gdk.Rectangle subarea; while (proc.Step(out subarea)) { ctx.Save(); SetClip(ctx, subarea); effect.OnExpose(ctx, Allocation); ctx.Restore(); } } } else { ctx.Operator = Operator.Source; SurfacePattern p = new SurfacePattern(current.Surface); p.Filter = Filter.Fast; SetClip(ctx, region); ctx.Matrix = current.Fill(Allocation); ctx.Source = p; ctx.Paint(); p.Destroy(); } }
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 (); }
public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds) { using (var similar = CairoUtils.CreateSurface(w.GdkWindow)) { Bounds = bounds; Surface = similar.CreateSimilar(Content.ColorAlpha, Bounds.Width, Bounds.Height); var ctx = new Context(Surface); ctx.Matrix = info.Fill(Bounds); Pattern p = new SurfacePattern(info.Surface); ctx.SetSource(p); ctx.Paint(); ctx.Dispose(); p.Dispose(); } }
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(); }
public ImageInfo(ImageInfo info, Gdk.Rectangle allocation) { Surface = info.Surface.CreateSimilar(Content.Color, allocation.Width, allocation.Height); var ctx = new Context(Surface); Bounds = allocation; ctx.Matrix = info.Fill(allocation); Pattern p = new SurfacePattern(info.Surface); ctx.SetSource(p); ctx.Paint(); ctx.Dispose(); p.Dispose(); }
public bool OnExpose(Context ctx, Gdk.Rectangle allocation) { ctx.Operator = Operator.Source; SurfacePattern p = new SurfacePattern(info.Surface); p.Filter = Filter.Fast; Matrix m = info.Fill(allocation, angle); ctx.Matrix = m; ctx.Source = p; ctx.Paint(); p.Destroy(); return(true); }
private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { MemorySurface surface = new MemorySurface (Format.Argb32, input.Width, input.Height); Context ctx = new Context (surface); ctx.Matrix = info.Fill (info.Bounds, angle); SurfacePattern p = new SurfacePattern (info.Surface); if (fast) { p.Filter = Filter.Fast; } ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); result = MemorySurface.CreatePixbuf (surface); surface.Flush (); } return result; }
private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { using (MemorySurface surface = new MemorySurface (Format.Argb32, input.Width, input.Height)) { using (Context ctx = new Context (surface)) { ctx.Matrix = info.Fill (info.Bounds, angle); using (SurfacePattern p = new SurfacePattern (info.Surface)) { if (fast) p.Filter = Filter.Fast; ctx.Source = p; ctx.Paint (); } result = MemorySurface.CreatePixbuf (surface); surface.Flush (); } } } return result; }
public ImageInfo(ImageInfo info, Gdk.Rectangle allocation) { Surface = info.Surface.CreateSimilar (Content.Color, allocation.Width, allocation.Height); var ctx = new Context (Surface); Bounds = allocation; ctx.Matrix = info.Fill (allocation); Pattern p = new SurfacePattern (info.Surface); ctx.SetSource (p); ctx.Paint (); ctx.Dispose (); p.Dispose (); }
public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds) { using (var similar = CairoUtils.CreateSurface (w.GdkWindow)) { Bounds = bounds; Surface = similar.CreateSimilar (Content.ColorAlpha, Bounds.Width, Bounds.Height); var ctx = new Context (Surface); ctx.Matrix = info.Fill (Bounds); Pattern p = new SurfacePattern (info.Surface); ctx.SetSource (p); ctx.Paint (); ctx.Dispose (); p.Dispose (); } }