WarpSettings.Style
Contents
[
Hide
]WarpSettings.Style property
Gets or sets style of warp
public WarpStyles Style { get; set; }
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
- enum WarpStyles
- class WarpSettings
- namespace Aspose.PSD.FileFormats.Psd.Layers.Warp
- assembly Aspose.PSD