Class UnitArrayStructure
UnitArrayStructure class
Defines the UnitArrayStructure class that holds Double values array and their measure unit. It is used in the PSD file resources, usually by ObjectArrayStructure
.
public sealed class UnitArrayStructure : OSTypeStructure
Constructors
Name | Description |
---|
UnitArrayStructure(ClassID, UnitTypes, double[]) | Initializes a new instance of the UnitArrayStructure class. |
Properties
Name | Description |
---|
override Key { get; } | Gets this unit array structure key. |
KeyName { get; set; } | Gets or sets the key name. |
override Length { get; } | Gets the OSTypeStructure length in bytes. |
UnitType { get; set; } | Gets or sets the measure unit type of the UnitArrayStructure values. |
ValueCount { get; } | Gets the value count. |
Values { get; set; } | Gets or sets the unit array structure values. |
Methods
Name | Description |
---|
virtual GetHeaderLength() | Gets the header length. |
Save(StreamContainer) | Saves the structure to the specified stream container. |
SaveWithoutKeyName(StreamContainer) | Saves the structure to the specified stream container. |
Fields
Name | Description |
---|
const StructureKey | Defines the ‘UnFl’ UnitArrayStructure key. |
Examples
The following code demonstrates the support of the ObAr and UnFl signatures.
[C#]
void AssertAreEqual(object actual, object expected)
{
if (!object.Equals(actual, expected))
{
throw new FormatException(string.Format("Actual value {0} are not equal to expected {1}.", actual, expected));
}
}
var sourceFilePath = "LayeredSmartObjects8bit2.psd";
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath))
{
UnitArrayStructure verticalStructure = null;
foreach (Layer imageLayer in image.Layers)
{
foreach (var imageResource in imageLayer.Resources)
{
var resource = imageResource as PlLdResource;
if (resource != null && resource.IsCustom)
{
foreach (OSTypeStructure structure in resource.Items)
{
if (structure.KeyName.ClassName == "customEnvelopeWarp")
{
AssertAreEqual(typeof(DescriptorStructure), structure.GetType());
var custom = (DescriptorStructure)structure;
AssertAreEqual(custom.Structures.Length, 1);
var mesh = custom.Structures[0];
AssertAreEqual(typeof(ObjectArrayStructure), mesh.GetType());
var meshObjectArray = (ObjectArrayStructure)mesh;
AssertAreEqual(meshObjectArray.Structures.Length, 2);
var vertical = meshObjectArray.Structures[1];
AssertAreEqual(typeof(UnitArrayStructure), vertical.GetType());
verticalStructure = (UnitArrayStructure)vertical;
AssertAreEqual(verticalStructure.UnitType, UnitTypes.Pixels);
AssertAreEqual(verticalStructure.ValueCount, 16);
break;
}
}
}
}
}
AssertAreEqual(true, verticalStructure != null);
}
See Also