CoordinateList <byte> GetControlPoints() { ObjcParameter objc = _adjustment[0] as ObjcParameter; ReferenceParameter obj = objc.Parameters["Chnl"] as ReferenceParameter; ListParameter curve = objc.Parameters["Crv"] as ListParameter; CoordinateList <byte> controlPoints = new CoordinateList <byte>(); // Dirty hack. Fixme! if (curve == null) { return(controlPoints); } foreach (Parameter parameter in curve) { ObjcParameter point = parameter as ObjcParameter; double x = (point.Parameters["Hrzn"] as DoubleParameter).Value; double y = (point.Parameters["Vrtc"] as DoubleParameter).Value; controlPoints.Add(new Coordinate <byte>((byte)x, (byte)y)); } return(controlPoints); }
override public bool Execute() { if (_adjustment != null) { ObjcParameter objc = _adjustment[0] as ObjcParameter; ReferenceParameter obj = objc.Parameters["Chnl"] as ReferenceParameter; string origChannel = (obj.Set[0] as EnmrType).Value; ListParameter curve = objc.Parameters["Crv"] as ListParameter; CoordinateList <byte> controlPoints = new CoordinateList <byte>(); foreach (Parameter parameter in curve) { ObjcParameter point = parameter as ObjcParameter; double x = (point.Parameters["Hrzn"] as DoubleParameter).Value; double y = (point.Parameters["Vrtc"] as DoubleParameter).Value; controlPoints.Add(new Coordinate <byte>((byte)x, (byte)y)); } HistogramChannel channel; switch (origChannel) { case "Cmps": channel = HistogramChannel.Value; break; case "Rd": channel = HistogramChannel.Red; break; case "Grn": channel = HistogramChannel.Green; break; case "Bl": channel = HistogramChannel.Blue; break; default: Console.WriteLine("CurvesEvent: " + origChannel); return(false); } ActiveDrawable.CurvesSpline(channel, controlPoints); } else { Console.WriteLine("CurvesEvent: adjustment == null?"); } return(true); }
override public bool Execute() { double x1 = _from.GetValueAsDouble("Hrzn"); double y1 = _from.GetValueAsDouble("Vrtc"); double x2 = _to.GetValueAsDouble("Hrzn"); double y2 = _to.GetValueAsDouble("Vrtc"); Console.WriteLine("from ({0}, {1}) to ({2}, {3})", x1, y1, x2, y2); // Fix me! GradientType gradientType; switch (_type.Value) { case "Lnr": gradientType = GradientType.Linear; break; default: Console.WriteLine("Gradient-2: " + _type.Value); gradientType = GradientType.Linear; break; } Gradient gradient; if (_gradient != null) { string name = _gradient.GetValueAsString("Nm"); Console.WriteLine("Name: " + name); ListParameter colors = _gradient.Parameters["Clrs"] as ListParameter; gradient = CreateGradient(name, colors); } else if (_with != null) { gradient = CreateGradient("Photoshop.Temp", _with); } else { Console.WriteLine("Gradient-3"); return(false); } Context.Push(); Context.Gradient = gradient; ActiveDrawable.EditBlend(BlendMode.Custom, LayerModeEffects.Normal, gradientType, 100.0, 0.0, RepeatMode.None, false, false, 0, 0, _dither, x1, y1, x2, y2); Context.Pop(); return(true); }
void SetBalance(ListParameter parameter, TransferMode transferMode) { int cyanRed = (parameter[0] as LongParameter).Value; int magentaGreen = (parameter[1] as LongParameter).Value; int yellowBlue = (parameter[2] as LongParameter).Value; if (cyanRed != 0 || magentaGreen != 0 || yellowBlue != 0) { ActiveDrawable.ColorBalance(transferMode, _preserveLuminosity, cyanRed, magentaGreen, yellowBlue); } }
/* * protected override IEnumerable ListParameters() * { * yield return "Type: " + Abbreviations.Get(_type.Value); * yield return ((_dither) ? "With" : "Without") + " Dither"; * yield return ((_useMask) ? "With" : "Without") + " Use Mask"; * } */ static public Gradient CreateGradient(string name, ListParameter colors) { Gradient gradient = new Gradient("Photoshop." + name); gradient.SegmentRangeSplitUniform(0, -1, colors.Count); int segment = 0; foreach (ObjcParameter parameter in colors) { RGB color; string type = parameter.GetValueAsString("Type"); switch (type) { case "BckC": color = Context.Background; break; case "FrgC": color = Context.Foreground; break; case "UsrS": color = parameter.GetValueAsColor("Clr"); break; default: Console.WriteLine("Gradient-1: " + type); color = new RGB(0, 0, 0); break; } long location = parameter.GetValueAsLong("Lctn"); long midpoint = parameter.GetValueAsLong("Mdpn"); Console.WriteLine("type: {0}, location: {1}, midpoint: {2}", type, location, midpoint); gradient.SegmentSetLeftPosition(segment, location / 4096.0); gradient.SegmentSetLeftColor(segment, color, 100); if (segment > 0) { gradient.SegmentSetRightColor(segment - 1, color, 100); } segment++; } return(gradient); }
/* protected override IEnumerable ListParameters() { yield return "Type: " + Abbreviations.Get(_type.Value); yield return ((_dither) ? "With" : "Without") + " Dither"; yield return ((_useMask) ? "With" : "Without") + " Use Mask"; } */ public static Gradient CreateGradient(string name, ListParameter colors) { Gradient gradient = new Gradient("Photoshop." + name); gradient.SegmentRangeSplitUniform(0, -1, colors.Count); int segment = 0; foreach (ObjcParameter parameter in colors) { RGB color; string type = parameter.GetValueAsString("Type"); switch (type) { case "BckC": color = Context.Background; break; case "FrgC": color = Context.Foreground; break; case "UsrS": color = parameter.GetValueAsColor("Clr"); break; default: Console.WriteLine("Gradient-1: " + type); color = new RGB(0, 0, 0); break; } long location = parameter.GetValueAsLong("Lctn"); long midpoint = parameter.GetValueAsLong("Mdpn"); Console.WriteLine("type: {0}, location: {1}, midpoint: {2}", type, location, midpoint); gradient.SegmentSetLeftPosition(segment, location / 4096.0); gradient.SegmentSetLeftColor(segment, color, 100); if (segment > 0) { gradient.SegmentSetRightColor(segment - 1, color, 100); } segment++; } return gradient; }
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); }