BlwhResource Class
BlwhResource class is a resource of Black and White Adjustment Layer.
Inheritance Hierarchy
SystemObject
  Aspose.PSD.FileFormats.Psd.LayersLayerResource
    Aspose.PSD.FileFormats.Psd.Layers.LayerResourcesAdjustmentLayerResource
      Aspose.PSD.FileFormats.Psd.Layers.LayerResourcesBlwhResource

Namespace: Aspose.PSD.FileFormats.Psd.Layers.LayerResources
Assembly: Aspose.PSD (in Aspose.PSD.dll) Version: 21.11
Syntax
public class BlwhResource : AdjustmentLayerResource

The BlwhResource type exposes the following members.

Constructors
  NameDescription
Public methodBlwhResource
Initializes a new instance of the BlwhResource class
Properties
  NameDescription
Public propertyCode exampleBlackAndWhitePresetFileName
Gets or sets the black and white preset file name.
Public propertyCode exampleBlues
Gets or sets the blues value.
Public propertyCode exampleBwPresetKind
Gets or sets the black and white preset kind value.
Public propertyCode exampleCyans
Gets or sets the cyans value.
Protected propertyData
Gets or sets the data.
(Inherited from AdjustmentLayerResource.)
Public propertyCode exampleGreens
Gets or sets the greens value.
Public propertyKey
Gets the layer resource key.
(Overrides LayerResourceKey.)
Public propertyLength
Gets the layer resource length in bytes.
(Overrides LayerResourceLength.)
Public propertyCode exampleMagentas
Gets or sets the magentas value.
Public propertyPsdVersion
Gets the psd version.
(Overrides LayerResourcePsdVersion.)
Public propertyCode exampleReds
Gets or sets the reds value.
Public propertySignature
Gets the signature.
(Inherited from AdjustmentLayerResource.)
Public propertyCode exampleTintColor
Gets or sets the Tint Color ARGB value.
Public propertyCode exampleUseTint
Gets or sets a value indicating whether [tint color] is used.
Public propertyCode exampleYellows
Gets or sets the yellows value.
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 AdjustmentLayerResourceSave(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 how you edit a BlwhResource.
[C#]

void AssertIsTrue(bool condition, string message)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}

const string ActualPropertyValueIsWrongMessage = "Expected property value is not equal to actual value";

string destinationFileName = "Output" + sourceFileName;
bool isRequiredResourceFound = false;
using (PsdImage im = (PsdImage)Image.Load(sourceFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is BlwhResource)
            {
                var blwhResource = (BlwhResource)layerResource;
                var blwhLayer = (BlackWhiteAdjustmentLayer)layer;
                isRequiredResourceFound = true;

                AssertIsTrue(blwhResource.Reds == reds, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Yellows == yellows, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Greens == greens, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Cyans == cyans, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Blues == blues, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Magentas == magentas, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.UseTint == useTint, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.TintColor == tintColor, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.BwPresetKind == bwPresetKind, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == bwPresetFileName, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed) < 1e-6, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen) < 1e-6, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue) < 1e-6, ActualPropertyValueIsWrongMessage);

                // Test editing and saving
                blwhResource.Reds = reds - 15;
                blwhResource.Yellows = yellows - 15;
                blwhResource.Greens = greens + 15;
                blwhResource.Cyans = cyans + 15;
                blwhResource.Blues = blues - 15;
                blwhResource.Magentas = magentas - 15;
                blwhResource.UseTint = !useTint;
                blwhResource.BwPresetKind = 4;
                blwhResource.BlackAndWhitePresetFileName = "bwPresetFileName";
                blwhLayer.TintColorRed = tintColorRed - 60;
                blwhLayer.TintColorGreen = tintColorGreen - 60;
                blwhLayer.TintColorBlue = tintColorBlue - 60;

                im.Save(destinationFileName);
                break;
            }
        }
    }
}

AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found");

isRequiredResourceFound = false;

using (PsdImage im = (PsdImage)Image.Load(destinationFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is BlwhResource)
            {
                var blwhResource = (BlwhResource)layerResource;
                var blwhLayer = (BlackWhiteAdjustmentLayer)layer;
                isRequiredResourceFound = true;

                AssertIsTrue(blwhResource.Reds == reds - 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Yellows == yellows - 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Greens == greens + 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Cyans == cyans + 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Blues == blues - 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.Magentas == magentas - 15, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.UseTint == !useTint, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.TintColor == newTintColor, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.BwPresetKind == 4, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == "bwPresetFileName", ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed + 60) < 1e-6, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen + 60) < 1e-6, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue + 60) < 1e-6, ActualPropertyValueIsWrongMessage);

                break;
            }
        }
    }
}

AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found");
See Also