override public bool Execute() { DoubleParameter width = Parameters["Wdth"] as DoubleParameter; if (width != null) { _width = width.GetPixels(ActiveImage.Width); } DoubleParameter height = Parameters["Hght"] as DoubleParameter; if (height != null) { _height = height.GetPixels(ActiveImage.Height); } if (_constrainProportions) { if (_width != 0 && _height == 0) { _height = ActiveImage.Height * _width / ActiveImage.Width; } if (_width == 0 && _height != 0) { _width = ActiveImage.Width * _height / ActiveImage.Height; } } ActiveImage.Scale((int)_width, (int)_height); return(true); }
protected override IEnumerable ListParameters() { ObjcParameter objc = Parameters["Ofst"] as ObjcParameter; if (objc != null) { yield return("Offset"); } DoubleParameter width = Parameters["Wdth"] as DoubleParameter; if (width != null) { yield return(width.Format()); } ObjcParameter position = Parameters["Pstn"] as ObjcParameter; if (position != null) { if (position.Contains("Hrzn")) { _horizontal = position.GetValueAsDouble("Hrzn"); } if (position.Contains("Vrtc")) { _vertical = position.GetValueAsDouble("Vrtc"); } yield return(String.Format("Position: {0}, {1}", _horizontal, _vertical)); } BoolParameter relative = Parameters["Rltv"] as BoolParameter; if (relative != null) { yield return(relative.Format("Relative")); } }
protected override IEnumerable ListParameters() { ObjcParameter objc = Parameters["Ofst"] as ObjcParameter; if (objc != null) { yield return("Offset"); } DoubleParameter width = Parameters["Wdth"] as DoubleParameter; if (width != null) { yield return("Width: " + width.Value); } DoubleParameter height = Parameters["Hght"] as DoubleParameter; if (height != null) { yield return("Height: " + height.Value); } }
override public bool Execute() { DoubleParameter width = Parameters["Wdth"] as DoubleParameter; double widthPercentage = (width == null) ? 100 : width.Value; DoubleParameter height = Parameters["Hght"] as DoubleParameter; double heightPercentage = (height == null) ? 100 : height.Value; bool nonEmpty; Rectangle bounds = ActiveImage.Selection.Bounds(out nonEmpty); double newWidth = bounds.Width * widthPercentage / 100; double newHeight = bounds.Height * heightPercentage / 100; // TODO: always rescale from the center double x = bounds.X1 + (bounds.Width - newWidth) / 2; double y = bounds.Y1 + (bounds.Height - newHeight) / 2; // TODO: for now assume that the selection is always rectangular RectangleSelectTool tool = new RectangleSelectTool(ActiveImage); tool.Select(x, y, newWidth, newHeight, ChannelOps.Replace, false, 0); return(true); }
public Parameter ReadItem() { string key; if (PreSix) { key = ReadFourByteString(); } else { key = ReadTokenOrString(); } string type = ReadFourByteString(); DebugOutput.Dump("key: {0} ({1})", key, type); Parameter parameter = null; switch (type) { case "alis": parameter = new AliasParameter(); break; case "UntF": parameter = new DoubleParameter(true); break; case "bool": parameter = new BoolParameter(); break; case "doub": parameter = new DoubleParameter(false); break; case "enum": parameter = new EnumParameter(); break; case "obj": parameter = new ReferenceParameter(); break; case "VlLs": parameter = new ListParameter(); break; case "long": parameter = new LongParameter(); break; case "Pth": parameter = new PathParameter(); break; case "TEXT": parameter = new TextParameter(); break; case "ObAr": parameter = new ObArParameter(); break; case "Objc": parameter = new ObjcParameter(); break; case "tdta": parameter = new RawDataParameter(); break; case "type": parameter = new TypeParameter(); break; default: Console.WriteLine("ReadItem: type {0} unknown!", type); throw new GimpSharpException(); } DebugOutput.Level++; parameter.Parse(this); DebugOutput.Level--; parameter.Name = key; return parameter; }
public Parameter ReadItem() { string key; if (PreSix) { key = ReadFourByteString(); } else { key = ReadTokenOrString(); } string type = ReadFourByteString(); DebugOutput.Dump($"key: {key} ({type})"); Parameter parameter = null; switch (type) { case "alis": parameter = new AliasParameter(); break; case "UntF": parameter = new DoubleParameter(true); break; case "bool": parameter = new BoolParameter(); break; case "doub": parameter = new DoubleParameter(false); break; case "enum": parameter = new EnumParameter(); break; case "obj": parameter = new ReferenceParameter(); break; case "VlLs": parameter = new ListParameter(); break; case "long": parameter = new LongParameter(); break; case "Pth": parameter = new PathParameter(); break; case "TEXT": parameter = new TextParameter(); break; case "ObAr": parameter = new ObArParameter(); break; case "Objc": parameter = new ObjcParameter(); break; case "tdta": parameter = new RawDataParameter(); break; case "type": parameter = new TypeParameter(); break; default: Console.WriteLine("ReadItem: type {0} unknown!", type); throw new GimpSharpException(); } DebugOutput.Level++; parameter.Parse(this); DebugOutput.Level--; parameter.Name = key; return(parameter); }