Class WarpSettings
Contents
[
Hide
]WarpSettings class
Parameters of layer with warp
public class WarpSettings
Constructors
Name | Description |
---|---|
WarpSettings(PlacedResource) | Initializes a new instance of the WarpSettings class. |
WarpSettings(OSTypeStructure[], Rectangle) | Initializes a new instance of the WarpSettings class. |
Properties
Name | Description |
---|---|
Bounds { get; } | Gets or sets bounds of warp image |
MeshPoints { get; set; } | Photoshop mesh points |
Rotate { get; set; } | Gets or sets rotate value |
Style { get; set; } | Gets or sets style of warp |
Value { get; set; } | Gets or sets value of warp |
Examples
The following code demonstrates how to manipulate WarpSettings to do warp transformation on SmartObjectLayer and TexLayer.
[C#]
string sourceFile = "smart_without_warp.psd";
var opt = new PsdLoadOptions()
{
LoadEffectsResource = true,
AllowWarpRepaint = true
};
string[] outputImageFile = new string[4];
string[] outputPsdFile = new string[4];
for (int caseIndex = 0; caseIndex < outputImageFile.Length; caseIndex++)
{
outputImageFile[caseIndex] = "export_" + caseIndex + ".png";
outputPsdFile[caseIndex] = "export_" + caseIndex + ".psd";
using (PsdImage img = (PsdImage)Image.Load(sourceFile, opt))
{
foreach (Layer layer in img.Layers)
{
if (layer is SmartObjectLayer)
{
var smartLayer = (SmartObjectLayer)layer;
smartLayer.WarpSettings = GetWarpSettingsByIndex(smartLayer.WarpSettings, caseIndex);
}
if (layer is TextLayer)
{
var textLayer = (TextLayer)layer;
if (caseIndex != 3)
{
textLayer.WarpSettings = GetWarpSettingsByIndex(textLayer.WarpSettings, caseIndex);
}
}
}
img.Save(outputPsdFile[caseIndex], new PsdOptions());
}
using (PsdImage img = (PsdImage)Image.Load(outputPsdFile[caseIndex], opt))
{
img.Save(outputImageFile[caseIndex],
new PngOptions() { CompressionLevel = 9, ColorType = PngColorType.TruecolorWithAlpha });
}
}
WarpSettings GetWarpSettingsByIndex(WarpSettings warpParams, int caseIndex)
{
switch (caseIndex)
{
case 0:
warpParams.Style = WarpStyles.Rise;
warpParams.Rotate = WarpRotates.Horizontal;
warpParams.Value = 20;
break;
case 1:
warpParams.Style = WarpStyles.Rise;
warpParams.Rotate = WarpRotates.Vertical;
warpParams.Value = 10;
break;
case 2:
warpParams.Style = WarpStyles.Flag;
warpParams.Rotate = WarpRotates.Horizontal;
warpParams.Value = 30;
break;
case 3:
warpParams.Style = WarpStyles.Custom;
warpParams.MeshPoints[2].Y += 70;
break;
}
return warpParams;
}
See Also
- namespace Aspose.PSD.FileFormats.Psd.Layers.Warp
- assembly Aspose.PSD