[C#]stringsourceFileName="ComplexGradientFillLayer.psd";stringexportPath="ComplexGradientFillLayer_after.psd";varim=(PsdImage)Image.Load(sourceFileName);using(im){foreach(varlayerinim.Layers){if(layerisFillLayer){varfillLayer=(FillLayer)layer;varresources=fillLayer.Resources;foreach(varresinresources){if(resisGdFlResource){// 読むvarresource=(GdFlResource)res;if(resource.AlignWithLayer!=false||(Math.Abs(resource.Angle-45.0)>0.001)||resource.Dither!=true||resource.Reverse!=false||resource.Color!=Color.Empty||Math.Abs(resource.HorizontalOffset-(-39))>0.001||Math.Abs(resource.VerticalOffset-(-5))>0.001||resource.TransparencyPoints.Length!=3||resource.ColorPoints.Length!=2){thrownewException("Resource Parameters were read wrong");}vartransparencyPoints=resource.TransparencyPoints;if(Math.Abs(100.0-transparencyPoints[0].Opacity)>0.25||transparencyPoints[0].Location!=0||transparencyPoints[0].MedianPointLocation!=50||Math.Abs(50.0-transparencyPoints[1].Opacity)>0.25||transparencyPoints[1].Location!=2048||transparencyPoints[1].MedianPointLocation!=50||Math.Abs(100.0-transparencyPoints[2].Opacity)>0.25||transparencyPoints[2].Location!=4096||transparencyPoints[2].MedianPointLocation!=50){thrownewException("Gradient Transparency Points were read Wrong");}varcolorPoints=resource.ColorPoints;if(colorPoints[0].Color!=Color.FromArgb(203,64,140)||colorPoints[0].Location!=0||colorPoints[0].MedianPointLocation!=50||colorPoints[1].Color!=Color.FromArgb(203,0,0)||colorPoints[1].Location!=4096||colorPoints[1].MedianPointLocation!=50){thrownewException("Gradient Color Points were read Wrong");}// 編集中resource.Angle=30.0;resource.Dither=false;resource.AlignWithLayer=true;resource.Reverse=true;resource.HorizontalOffset=25;resource.VerticalOffset=-15;varnewColorPoints=newList<IGradientColorPoint>(resource.ColorPoints);varnewTransparencyPoints=newList<IGradientTransparencyPoint>(resource.TransparencyPoints);newColorPoints.Add(newGradientColorPoint(){Color=Color.Violet,Location=4096,MedianPointLocation=75});colorPoints[1].Location=3000;newTransparencyPoints.Add(newGradientTransparencyPoint(){Opacity=80.0,Location=4096,MedianPointLocation=25});transparencyPoints[2].Location=3000;resource.ColorPoints=newColorPoints.ToArray();resource.TransparencyPoints=newTransparencyPoints.ToArray();im.Save(exportPath);}break;}break;}}}