Ejemplo n.º 1
0
        private void HandleNodeComputed(object o, Gegl.Rectangle rectangle)
        {
            rectangle.X      = (int)(Scale * (rectangle.X - X));
            rectangle.Y      = (int)(Scale * (rectangle.Y - Y));
            rectangle.Width  = (int)Math.Ceiling(rectangle.Width * Scale);
            rectangle.Height = (int)Math.Ceiling(rectangle.Height * Scale);

            QueueDrawArea(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
        }
Ejemplo n.º 2
0
        public void Repaint(int width, int height)
        {
            //Gegl.Rectangle roi = new Gegl.Rectangle(x, y, Allocation.Width / scale, Allocation.Height/scale);
            processor_rect = new Gegl.Rectangle();
            processor_rect.Set(x, y, (uint) (width / scale), (uint) (height/scale));
            Processor.Rectangle = processor_rect;

            // refresh view twice a second
            if (timeout_id == 0) {
                timeout_id = GLib.Timeout.Add(200, delegate {
                    double progress;
		    Console.WriteLine("working: " + Allocation.Width + " " + Allocation.Height + " " + processor_rect.Width + " " + processor_rect.Height);
                    bool more = Processor.Work(out progress);
                    if (!more)
		    {
			HandleNodeComputed(null, processor_rect);
                        timeout_id = 0;
		    }

                    return more;
                });
            }
        }
Ejemplo n.º 3
0
        private void HandleViewExposed(object sender, ExposeEventArgs args)
        {
            Console.WriteLine("exposed");
            if (Node != null)
            {
                foreach (Gdk.Rectangle rect in args.Event.Region.GetRectangles())
                {
                    Gegl.Rectangle roi = new Gegl.Rectangle();
                    roi.Set((int)(X + rect.X / Scale), (int)(Y + rect.Y / Scale), (uint)rect.Width, (uint)rect.Height);

                    byte [] buf = Node.Render(roi, Scale, "R'G'B' u8", Gegl.BlitFlags.Cache | Gegl.BlitFlags.Dirty);

                    this.GdkWindow.DrawRgbImage(
                        Style.WhiteGC,
                        rect.X, rect.Y,
                        rect.Width, rect.Height,
                        Gdk.RgbDither.None, buf, rect.Width * 3
                        );
                }
            }

            args.RetVal = false;  // returning false here, allows cairo to hook in and draw more
        }
Ejemplo n.º 4
0
        public void Repaint(int width, int height)
        {
            //Gegl.Rectangle roi = new Gegl.Rectangle(x, y, Allocation.Width / scale, Allocation.Height/scale);
            processor_rect = new Gegl.Rectangle();
            processor_rect.Set(x, y, (uint)(width / scale), (uint)(height / scale));
            Processor.Rectangle = processor_rect;

            // refresh view twice a second
            if (timeout_id == 0)
            {
                timeout_id = GLib.Timeout.Add(200, delegate {
                    double progress;
                    Console.WriteLine("working: " + Allocation.Width + " " + Allocation.Height + " " + processor_rect.Width + " " + processor_rect.Height);
                    bool more = Processor.Work(out progress);
                    if (!more)
                    {
                        HandleNodeComputed(null, processor_rect);
                        timeout_id = 0;
                    }

                    return(more);
                });
            }
        }
Ejemplo n.º 5
0
        private void HandleViewExposed(object sender, ExposeEventArgs args)
        {
	    Console.WriteLine("exposed");
            if (Node != null) {
                foreach (Gdk.Rectangle rect in args.Event.Region.GetRectangles()) {
                    Gegl.Rectangle roi = new Gegl.Rectangle();
                    roi.Set((int) (X + rect.X/Scale), (int) (Y + rect.Y/Scale), (uint) rect.Width, (uint) rect.Height);

                    byte [] buf = Node.Render(roi, Scale, "R'G'B' u8", Gegl.BlitFlags.Cache | Gegl.BlitFlags.Dirty);
                    
                    this.GdkWindow.DrawRgbImage(
                        Style.WhiteGC,
                        rect.X, rect.Y,
                        rect.Width, rect.Height,
                        Gdk.RgbDither.None, buf, rect.Width*3
                    );
                }
            }

            args.RetVal = false;  // returning false here, allows cairo to hook in and draw more
        }