예제 #1
0
        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);
        }
        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);
                    }
                }
            }
        }
		private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) {
			Pixbuf result;
			using (ImageInfo info = new ImageInfo (input)) {
				Widgets.SoftFocus soft = new Widgets.SoftFocus (info);
				soft.Radius = radius;

				MemorySurface surface = new MemorySurface (Format.Argb32,
									   input.Width,
									   input.Height);

				Context ctx = new Context (surface);
				soft.Apply (ctx, info.Bounds);
				((IDisposable)ctx).Dispose ();

				result = MemorySurface.CreatePixbuf (surface);
				surface.Flush ();
			}
			return result;
		}
예제 #4
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                Widgets.SoftFocus soft = new Widgets.SoftFocus(info);
                soft.Radius = radius;

                MemorySurface surface = new MemorySurface(Format.Argb32,
                                                          input.Width,
                                                          input.Height);

                Context ctx = new Context(surface);
                soft.Apply(ctx, info.Bounds);
                ((IDisposable)ctx).Dispose();

                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)) {
				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;
		}
예제 #6
0
 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;
 }