Beispiel #1
0
 public AspectPreview(Drawable drawable, bool toggle = false)
     : base(gimp_aspect_preview_new(drawable.Ptr, toggle))
 {
     _drawableWidth = drawable.Width;
       _drawableHeight = drawable.Height;
       _bpp = drawable.Bpp;
 }
 public void Init()
 {
     _image = new Image(_width, _height, ImageBaseType.Rgb) {
     {new Layer(_image, "test", _width, _height, ImageType.Rgb, 100,
        LayerModeEffects.Normal), 0}};
       _drawable = _image.ActiveDrawable;
 }
 public void Attach(Drawable drawable)
 {
     if (!gimp_floating_sel_attach(_ID, drawable.ID))
     {
       throw new GimpSharpException();
     }
 }
Beispiel #4
0
        private Rectangle _rectangle; // mask bounds

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a GSImage backed with an existing Drawable.
        /// </summary>
        /// <param name="drawable"></param>
        public GSImage(Drawable drawable)
        {
            _image = drawable.Image;
            _drawable = drawable;
            _rectangle = _drawable.MaskBounds;
            Tile.CacheDefault(_drawable);
            Progress = new Progress("Halftone Laboratory");
        }
Beispiel #5
0
        public void Draw(Drawable drawable)
        {
            var rgn = new PixelRgn(drawable, false, false);

              var rectangle = drawable.Bounds;
              var buf = rgn.GetRect(rectangle);
              Draw(rectangle, drawable.Type, buf, rectangle.Width * drawable.Bpp);
        }
Beispiel #6
0
        public void Init()
        {
            _image = new Image(_width, _height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgb), 0}};

              _drawable = _image.ActiveDrawable;
              _selection = _image.Selection;
        }
Beispiel #7
0
        public PixelRgn(Drawable drawable, int x, int y, int width, int height,
		    bool dirty, bool shadow)
        {
            pr = (GimpPixelRgn*)g_malloc(sizeof(GimpPixelRgn));
              gimp_pixel_rgn_init(ref *pr, drawable.Ptr, x, y, width, height, dirty,
            shadow);
              _bpp = (int) pr->bpp;
              _dummy = new byte[pr->bpp];
              _dirty = dirty;
              _drawable = drawable;
        }
Beispiel #8
0
 /// <summary>
 /// Create a GSImage backed with a new %Gimp# Image.
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public GSImage(int width, int height)
 {
     _image = new Gimp.Image(width, height, ImageBaseType.Gray);
     Layer layer = new Layer(_image, "default", width, height,
         ImageType.Gray, 100, LayerModeEffects.Normal);
     _image.AddLayer(layer, 0);
     _drawable = _image.ActiveDrawable;
     _rectangle = _drawable.MaskBounds;
     Tile.CacheDefault(_drawable);
     Progress = new Progress("Halftone Laboratory");
 }
        public GimpDialogWithPreview(string title, Drawable drawable, 
				 VariableSet variables, 
				 Func<GimpPreview> factory)
            : base(title, variables)
        {
            Drawable = drawable;

              Vbox = new VBox(false, 0) {BorderWidth = 12};
              VBox.PackStart(Vbox, true, true, 0);

              Preview = factory();

              Preview.Invalidated += delegate {UpdatePreview(Preview);};

              Vbox.PackStart(Preview, true, true, 0);

              variables.ValueChanged += delegate {InvalidatePreview();};
        }
        public Rectangle MinDistanceRegion(Rectangle sourceRect, Drawable drawable, SelectionMask selectionMask)
        {
            Debug.Assert(sourceRect.Width == sourceRect.Height);

            var windowSize = sourceRect.Width;
            var windowDelta = windowSize/2;
            Rectangle minRegionRect = null;

            var minDistance = 0.0;

            var sourceRgn = new PixelRgn(drawable, sourceRect.AdjustedToImageEdges(drawable.Bounds), false, false);
            var sourceArray = sourceRgn.ToArrayWithoutSelection(selectionMask);

            var currentCoordinate = new IntCoordinate(0, 0);
            for (int i = windowDelta; i < drawable.Width - windowDelta; i++)
            {
                for (int j = windowDelta; j < drawable.Height - windowDelta; j++)
                {
                    if (j == sourceRect.Y1 + windowDelta && i == sourceRect.X1 + windowDelta)
                    {
                        continue;
                    }
                    currentCoordinate.X = i;
                    currentCoordinate.Y = j;
                    var currentRgnRect = currentCoordinate.PointCenteredRectangle(windowSize);
                    var dist = RegionDistance(sourceArray, currentRgnRect, drawable, selectionMask);
                    if (dist == null)
                    {
                        continue;
                    }
                    if (dist == 0)
                    {
                        return currentRgnRect;
                    }
                    if ((minDistance > dist || minRegionRect == null))
                    {
                        minDistance = (double) dist;
                        minRegionRect = currentRgnRect;
                    }
                }
            }

            return minRegionRect;
        }
Beispiel #11
0
 public ZoomPreview(Drawable drawable, ZoomModel model)
     : base(gimp_zoom_preview_new_with_model(drawable.Ptr, model.Ptr))
 {
     Drawable = drawable;
 }
Beispiel #12
0
 /// <summary>
 /// Scale the image with a given factor and interpolation.
 /// </summary>
 /// <remarks>
 /// If there is an buffer, it gets flushed before scaling.
 /// </remarks>
 /// <param name="factor">Resize factor (< 1.0 = downscale, >1.0 =
 /// upscale)</param>
 /// <param name="interpolation">Interpolation type</param>
 /// <param name="direction">Scale direction (forward = scale by factor,
 /// backward = scale by 1/factor)</param>
 public void scale(double factor, InterpolationType interpolation,
     TransformDirection direction)
 {
     bool restoreBuffer = _imageBuffer != null;
     if (restoreBuffer) {
         flushBuffer();
     }
     double newHeight = Height * factor;
     double newWidth = Width * factor;
     Image.UndoGroupStart();
     Drawable.TransformScale(0, 0, newWidth, newHeight,
         direction, interpolation, false, 1, false);
     Image.ResizeToLayers();
     Image.UndoGroupEnd();
     _drawable = Image.ActiveDrawable;
     _rectangle = Drawable.MaskBounds;
     if (restoreBuffer) {
         initBuffer();
     }
 }
Beispiel #13
0
 public static void CacheDefault(Drawable drawable)
 {
     CacheNtiles = (ulong) (2 * (drawable.Width / Gimp.TileWidth + 1));
 }
 public FuzzySelectTool(Drawable drawable)
 {
     _drawableID = drawable.ID;
 }
Beispiel #15
0
 public RgnIterator(Drawable drawable, String progressText)
     : this(drawable, RunMode.Interactive)
 {
     Progress = new Progress(progressText);
 }
Beispiel #16
0
 // Used internally to save a single drawable
 internal bool Save(Drawable drawable, string filename)
 {
     return gimp_file_save(RunMode.Noninteractive, ID, drawable.ID,
         filename, filename);
 }
Beispiel #17
0
 internal virtual GimpPreview Instantiate(Drawable drawable)
 {
     return null;
 }
        public ReadPixelIterator(Drawable drawable, 
			     RunMode runmode = RunMode.Noninteractive)
        {
            _drawable = drawable;
              _runmode = runmode;
        }
Beispiel #19
0
 public DrawablePreview(Drawable drawable, bool toggle = false)
     : base(gimp_drawable_preview_new(drawable.Ptr, toggle))
 {
     Drawable = drawable;
       _bpp = drawable.Bpp;
 }
Beispiel #20
0
 public RgnIterator(Drawable drawable, RunMode runmode)
 {
     _drawable = drawable;
       _runmode = runmode;
       _rectangle = drawable.MaskBounds;
 }
 public ByColorSelectTool(Drawable drawable)
 {
     _drawableID = drawable.ID;
 }
Beispiel #22
0
        void FillDrawable(Drawable drawable, Pixel pixel)
        {
            var rgn = new PixelRgn(drawable, true, false);

              for (IntPtr pr = PixelRgn.Register(rgn); pr != IntPtr.Zero;
               pr = PixelRgn.Process(pr))
            {
              for (int y = rgn.Y; y < rgn.Y + rgn.H; y++)
            {
              for (int x = rgn.X; x < rgn.X + rgn.W; x++)
            {
              rgn[y, x] = pixel;
            }
            }
            }
        }
Beispiel #23
0
        public RGB PickColor(Drawable drawable, Coordinate<double> c,
                         bool sampleMerged, bool sampleAverage, 
			 double averageRadius)
        {
            GimpRGB color;
              if (!gimp_image_pick_color(ID, drawable.ID, c.X, c.Y,
                 sampleMerged, sampleAverage, averageRadius,
                 out color))
            {
              return null;
            }
              return new RGB(color);
        }
 public ZoomPreview(Drawable drawable)
     : base(gimp_zoom_preview_new(drawable.Ptr))
 {
     Drawable = drawable;
 }
Beispiel #25
0
        public void Redraw(Drawable drawable)
        {
            var rectangle = Bounds;
              int bpp = drawable.Bpp;
              int rowStride = rectangle.Width * bpp;
              var buffer = new byte[rectangle.Area * bpp];

              foreach (var pixel in new ReadPixelIterator(drawable))
            {
              int index = pixel.Y * rowStride + pixel.X * bpp;
              pixel.CopyTo(buffer, index);
            }
              DrawBuffer(buffer, rowStride);
        }
Beispiel #26
0
        public PixelRgn(Drawable drawable, Rectangle rectangle, bool dirty,
		    bool shadow)
            : this(drawable, rectangle.X1, rectangle.Y1, rectangle.Width,
	   rectangle.Height, dirty, shadow)
        {
        }
        public double? RegionDistance(Pixel[,] source, Rectangle rgnRect, Drawable drawable, SelectionMask selectionMask)
        {
            var sum = 0.0;
            var sourceWidth = source.GetLength(0);
            var sourceHeight = source.GetLength(1);
            var rgn = new PixelRgn(drawable, rgnRect, false, false);
            for (IntPtr pr = PixelRgn.Register(rgn);
                 pr != IntPtr.Zero;
                 pr = PixelRgn.Process(pr))
            {
                for (int y1 = rgn.Y - rgnRect.UpperLeft.Y, y2 = rgn.Y;
                     y2 < rgn.Y + rgn.H;
                     y1++, y2++)
                {
                    for (int x1 = rgn.X - rgnRect.UpperLeft.X, x2 = rgn.X;
                         x2 < rgn.X + rgn.W;
                         x1++, x2++)
                    {
                        if (selectionMask[x2, y2])
                        {
                            return null;
                        }
                        if (x1 >= sourceWidth ||
                            x2 >= sourceHeight ||
                            source[x1, y1] == null)
                        {
                            continue;
                        }

                        sum += DistanceSqr(source[x1, y1], rgn[y2, x2]);
                    }
                }
            }

            return sum;
        }
Beispiel #28
0
 public PixelRgn(Drawable drawable,  bool dirty, bool shadow)
     : this(drawable, 0, 0, drawable.Width, drawable.Height, dirty, shadow)
 {
 }
 public Layer Float(Drawable drawable, int offx, int offy)
 {
     return new Layer(gimp_selection_float(_imageID,
                 drawable.ID, offx, offy));
 }
Beispiel #30
0
 protected virtual bool Save(Image image, Drawable drawable, 
     string filename)
 {
     return false;
 }