PtFlResource Class
Class PtFlResource. Contains Pattern Fill Layer Data.
Inheritance Hierarchy
SystemObject
  Aspose.PSD.FileFormats.Psd.LayersLayerResource
    Aspose.PSD.FileFormats.Psd.Layers.LayerResourcesFillLayerResource
      Aspose.PSD.FileFormats.Psd.Layers.LayerResourcesPtFlResource

Namespace: Aspose.PSD.FileFormats.Psd.Layers.LayerResources
Assembly: Aspose.PSD (in Aspose.PSD.dll) Version: 21.12
Syntax
public class PtFlResource : FillLayerResource

The PtFlResource type exposes the following members.

Constructors
  NameDescription
Public methodPtFlResource
Initializes a new instance of the PtFlResource class.
Properties
  NameDescription
Public propertyCode exampleAlignWithLayer
Gets or sets a value indicating whether [align with layer].
Public propertyCode exampleIsLinkedWithLayer
Gets or sets a value indicating whether this instance is linked with layer.
Public propertyKey
Gets the layer resource key.
(Overrides LayerResourceKey.)
Public propertyLength
Gets the layer resource length in bytes.
(Overrides LayerResourceLength.)
Public propertyCode exampleOffset
Gets or sets the offset.
Public propertyPatternId
Gets or sets the pattern identifier.
Public propertyPatternName
Gets or sets the name of the pattern.
Public propertyPsdVersion
Gets the minimal psd version required for layer resource. 0 indicates no restrictions.
(Overrides LayerResourcePsdVersion.)
Public propertyCode exampleScale
Gets or sets the scale.
Public propertySignature
Gets the layer resource signature.
(Overrides FillLayerResourceSignature.)
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSave
Saves the resource to the specified stream container.
(Overrides LayerResourceSave(StreamContainer, Int32).)
Protected methodSaveResourceHeader
Saves the resource header.
(Inherited from LayerResource.)
Public methodToString
Returns a String that represents this instance.
(Inherited from LayerResource.)
Fields
  NameDescription
Public fieldStatic memberTypeToolKey
The type tool info key.
Examples
The following example demonstrates the support of the loading and editing a PtFlResource resource.
[C#]

string sourceFileName = "PatternFillLayer.psd";
string exportPath = "PtFlResource_Edited.psd";
double tolerance = 0.0001;
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 PtFlResource)
                {
                    // Reading
                    PtFlResource resource = (PtFlResource)res;
                    if (
                        resource.Offset.X != -46 ||
                        resource.Offset.Y != -45 ||
                        resource.PatternId != "a6818df2-7532-494e-9615-8fdd6b7f38e5\0" ||
                        resource.PatternName != "$$$/Presets/Patterns/OpticalSquares=Optical Squares\0" ||
                        resource.AlignWithLayer != true ||
                        resource.IsLinkedWithLayer != true ||
                        !(Math.Abs(resource.Scale - 50) < tolerance))
                    {
                        throw new Exception("PtFl Resource was read incorrect");
                    }

                    // Editing
                    resource.Offset = new Point(-11, 13);
                    resource.Scale = 200;
                    resource.AlignWithLayer = false;
                    resource.IsLinkedWithLayer = false;
                    fillLayer.Resources = fillLayer.Resources;
                    // We haven't pattern data in PattResource, so we can add it.
                    var fillSettings = (PatternFillSettings)fillLayer.FillSettings;
                    fillSettings.PatternData = new int[]
                    {
                                    Color.Black.ToArgb(),
                                    Color.White.ToArgb(),
                                    Color.White.ToArgb(),
                                    Color.White.ToArgb(),
                    };
                    fillSettings.PatternHeight = 1;
                    fillSettings.PatternWidth = 4;
                    fillSettings.PatternName = "$$$/Presets/Patterns/VerticalLine=Vertical Line New\0";
                    fillSettings.PatternId = Guid.NewGuid().ToString() + "\0";
                    fillLayer.Update();
                }
                break;
            }
            break;
        }
    }

    im.Save(exportPath);
}
See Also