Beispiel #1
0
        // Each handler here should contain Application.Invoke

        void HandleRenderingQueueItemRendering(object sender, RenderingTaskEventArgs e)
        {
            Application.Invoke(delegate {
                FloatBitmapGtk renderDest = (FloatBitmapGtk)e.Target.Stage.CurrentImage;

                // Drawing to pixbuf and saving to file
                using (Gdk.Pixbuf rp = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, renderDest.Width, renderDest.Height))
                {
                    renderDest.DrawToPixbuf(rp,
                                            delegate(double progress) {
                        // TODO: report progress via RenderingTask (needed to create an event)
                        //rpw.SetStatusAndProgress(progress, "Saving image...");
                        return(true);
                    }
                                            );

                    // TODO: "quality" must be specified for jpeg only.
                    // For png it should be "tEXt" fields.
                    // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html
                    rp.Savev(e.Target.Destination, e.Target.FileType, new string[] { "quality" }, new string[] { "95" });
                }
            });
        }
        // Each handler here should contain Application.Invoke
        void HandleRenderingQueueItemRendering(object sender, RenderingTaskEventArgs e)
        {
            Application.Invoke(delegate {
                FloatBitmapGtk renderDest = (FloatBitmapGtk)e.Target.Stage.CurrentImage;

                // Drawing to pixbuf and saving to file
                using (Gdk.Pixbuf rp = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, renderDest.Width, renderDest.Height))
                {

                    renderDest.DrawToPixbuf(rp,
                        delegate (double progress) {

                            // TODO: report progress via RenderingTask (needed to create an event)
                            //rpw.SetStatusAndProgress(progress, "Saving image...");
                            return true;
                        }
                    );

                    // TODO: "quality" must be specified for jpeg only.
                    // For png it should be "tEXt" fields.
                    // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html
                    rp.Savev(e.Target.Destination, e.Target.FileType, new string[] { "quality" }, new string[] { "95" });
                }
            });
        }