Class GdFlResource
GdFlResource class
Class GdFlResource. This resource contains information about blending of clipped element.
public class GdFlResource : FillLayerResource
Constructors
Properties
Name | Description |
---|
AlignWithLayer { get; set; } | Gets or sets a value indicating whether [align with layer]. |
Angle { get; set; } | Gets or sets the angle. |
Color { get; set; } | Gets the color of the RGB. |
ColorModel { get; set; } | Color Model - RGB/HSB/LAB (“RGBC”/“HSBl”/“LbCl”). |
ColorPoints { get; set; } | Gets the color points. |
Dither { get; set; } | Gets or sets a value indicating whether this GdFlResource is dither. |
GradientInterval { get; set; } | Gets or sets the gradient interval. |
GradientMode { get; set; } | Mode for this gradient. Determines ‘Gradient Type’ = ‘Solid/Noise’ = “CstS”/“ClNs”. |
GradientName { get; set; } | Gets or sets the name of the gradient. |
GradientType { get; set; } | Gets or sets the type of the gradient. |
HorizontalOffset { get; set; } | Gets or sets the horizontal offset. |
override Key { get; } | Gets the layer resource key. |
override Length { get; } | Gets the layer resource length in bytes. |
MaximumColor { get; set; } | Maximum color of PixelDataFormat. |
MinimumColor { get; set; } | Minimum color of PixelDataFormat. |
override PsdVersion { get; } | Gets the minimal psd version required for layer resource. 0 indicates no restrictions. |
Reverse { get; set; } | Gets or sets a value indicating whether this GdFlResource is reverse. |
RndNumberSeed { get; set; } | The random number seed used to generate colors for Noise gradient. |
Roughness { get; set; } | Roughness factor. |
Scale { get; set; } | Gets or sets the scale. |
ShowTransparency { get; set; } | Flag for showing transparency. |
override Signature { get; } | Gets the layer resource signature. |
TransparencyPoints { get; set; } | Gets the transparency points. |
UseVectorColor { get; set; } | Flag for using vector color. |
VerticalOffset { get; set; } | Gets or sets the vertical offset. |
Methods
Name | Description |
---|
override Save(StreamContainer, int) | Saves the resource to the specified stream container. |
override ToString() | Returns a String that represents this instance. |
Fields
Name | Description |
---|
const TypeToolKey | The type tool info key. |
Examples
The following example demonstrates the support of GdFlResource resource loading.
[C#]
string sourceFileName = "ComplexGradientFillLayer.psd";
string exportPath = "ComplexGradientFillLayer_after.psd";
var im = (PsdImage)Image.Load(sourceFileName);
using (im)
{
foreach (var layer in im.Layers)
{
if (layer is FillLayer)
{
var fillLayer = (FillLayer)layer;
var resources = fillLayer.Resources;
foreach (var res in resources)
{
if (res is GdFlResource)
{
// Reading
var resource = (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)
{
throw new Exception("Resource Parameters were read wrong");
}
var transparencyPoints = 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)
{
throw new Exception("Gradient Transparency Points were read Wrong");
}
var colorPoints = 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)
{
throw new Exception("Gradient Color Points were read Wrong");
}
// Editing
resource.Angle = 30.0;
resource.Dither = false;
resource.AlignWithLayer = true;
resource.Reverse = true;
resource.HorizontalOffset = 25;
resource.VerticalOffset = -15;
var newColorPoints = new List<IGradientColorPoint>(resource.ColorPoints);
var
newTransparencyPoints = new
List<IGradientTransparencyPoint>(resource.TransparencyPoints);
newColorPoints.Add(new GradientColorPoint()
{
Color = Color.Violet,
Location = 4096,
MedianPointLocation = 75
});
colorPoints[1].Location = 3000;
newTransparencyPoints.Add(new GradientTransparencyPoint()
{
Opacity = 80.0,
Location = 4096,
MedianPointLocation = 25
});
transparencyPoints[2].Location = 3000;
resource.ColorPoints = newColorPoints.ToArray();
resource.TransparencyPoints = newTransparencyPoints.ToArray();
im.Save(exportPath);
}
break;
}
break;
}
}
}
See Also