コード例 #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);
        }
コード例 #2
0
ファイル: TiltEditor.cs プロジェクト: neuroradiology/f-spot
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                using (ImageSurface surface = new ImageSurface(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 = surface.ToPixbuf();
                        surface.Flush();
                    }
                }
            }
            return(result);
        }
コード例 #3
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);
                    }
                }
            }
        }