Aspose.PSD for .NET 19.11 - 发行说明

关键 摘要 类别
PSDNET-151 支持内部阴影图层效果 特性
PSDNET-135 实现填充图层:图案的渲染 特性
PSDNET-187 支持AI格式文件中的光栅图像 特性
PSDNET-225 获取文本图层内联格式的属性 特性
PSDNET-214 如果 PSD 包含图层效果和调整图层,则导出到其他格式时会出现错误 错误

公共 API 更改

添加的 API:

  • T:Aspose.PSD.FileFormats.Ai.AiSection
  • M:Aspose.PSD.FileFormats.Ai.AiSection.GetData
  • P:Aspose.PSD.FileFormats.Ai.AiImage.Layers
  • M:Aspose.PSD.FileFormats.Ai.AiImage.AddLayer(Aspose.PSD.FileFormats.Ai.AiLayerSection)
  • T:Aspose.PSD.FileFormats.Ai.AiLayerSection
  • P:Aspose.PSD.FileFormats.Ai.AiLayerSection.RasterImages
  • M:Aspose.PSD.FileFormats.Ai.AiLayerSection.AddRasterImage(Aspose.PSD.FileFormats.Ai.AiRasterImageSection)
  • T:Aspose.PSD.FileFormats.Ai.AiRasterImageSection
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.Name
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.Pixels
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.ImageRectangle
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.OffsetX
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.OffsetY
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.Width
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.Angle
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.LeftBottomShift
  • P:Aspose.PSD.FileFormats.Ai.AiRasterImageSection.Height
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.BlendingOptions.AddInnerShadow
  • T:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Color
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.BlendMode
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.IsVisible
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Opacity
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Angle
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.UseGlobalLight
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Distance
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Spread
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Size
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.InnerShadowEffect.Noise
  • T:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Color
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Angle
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.UseGlobalLight
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Distance
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Spread
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Size
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.IShadowEffect.Noise
  • M:Aspose.PSD.FileFormats.Psd.Layers.TextLayer.GetFonts
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.FontIndex
  • T:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.FontType
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.Script
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.Synthetic
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.PostScriptName
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.FamilyName
  • P:Aspose.PSD.FileFormats.Psd.Layers.Text.TextFontInfo.Style

已移除的 API:

  • M:Aspose.PSD.FileFormats.Ai.AiFinalizeSection.GetData
  • M:Aspose.PSD.FileFormats.Ai.AiSetupSection.GetData

用法示例:

PSDNET-151. 支持内部阴影图层效果

            string sourceFile = "sample.psd";

            string destName = "sample_out.psd";

            var loadOptions = new PsdLoadOptions()

            {

                LoadEffectsResource = true

            };

            // Load an existing image into an instance of PsdImage class

            using (var image = (PsdImage)Image.Load(sourceFile, loadOptions))

            {

                var layer = image.Layers[image.Layers.Length - 1];

                var shadowEffect = (IShadowEffect)layer.BlendingOptions.Effects[0];

                shadowEffect.Color = Color.Green;

                shadowEffect.Opacity = 128;

                shadowEffect.Distance = 1;

                shadowEffect.UseGlobalLight = false;

                shadowEffect.Size = 2;

                shadowEffect.Angle = 45;

                shadowEffect.Spread = 50;

                shadowEffect.Noise = 5;

                image.Save(destName, new PsdOptions(image));

            }

PSDNET-135. 实现填充图层:图案的渲染

            string sourceFile = "sample.psd";

            string destName = "sample_out.psd";

            // Load an existing image into an instance of PsdImage class

            using (var image = (PsdImage)Image.Load(sourceFile))

            {

                foreach (var layer in image.Layers)

                {

                    if (layer is FillLayer)

                    {

                        var fillLayer = (FillLayer)layer;

                        var settings = (IPatternFillSettings)fillLayer.FillSettings;

                        settings.HorizontalOffset = -5;

                        settings.VerticalOffset = 12;

                        settings.Scale = 300;

                        settings.Linked = true;

                        settings.PatternData = new int[]

                                                   {

                                                       Color.Black.ToArgb(), Color.Red.ToArgb(),

                                                       Color.Green.ToArgb(), Color.Blue.ToArgb(),

                                                       Color.White.ToArgb(), Color.AliceBlue.ToArgb(),

                                                       Color.Violet.ToArgb(), Color.Chocolate.ToArgb(),

                                                       Color.IndianRed.ToArgb(), Color.DarkOliveGreen.ToArgb(),

                                                       Color.CadetBlue.ToArgb(), Color.YellowGreen.ToArgb(),

                                                       Color.Black.ToArgb(), Color.Azure.ToArgb(),

                                                       Color.ForestGreen.ToArgb(), Color.Sienna.ToArgb(),

                                                   };

                        settings.PatternHeight = 4;

                        settings.PatternWidth = 4;

                        settings.PatternName = "$$$/Presets/Patterns/ColorfulSquare=Colorful Square New\0";

                        settings.PatternId = Guid.NewGuid().ToString() + "\0";

                        fillLayer.Update();

                        break;

                    }

                }

                image.Save(destName, new PsdOptions(image));

            }

PSDNET-187. 支持AI格式文件中的光栅图像

            const double DefaultTolerance = 1e-6;

void AssertIsTrue(bool condition, string message) {

 if (!condition) {

  throw new FormatException(message);

 }

}

string sourceFile = "sample.ai";

using(AiImage image = (AiImage) Image.Load(sourceFile)) {

 AiLayerSection layer = image.Layers[0];

 AssertIsTrue(layer.RasterImages != null, "RasterImages property should be not null");

 AssertIsTrue(layer.RasterImages.Length == 1, "RasterImages property should contain exactly one item");

 AiRasterImageSection rasterImage = layer.RasterImages[0];

 AssertIsTrue(rasterImage.Pixels != null, "rasterImage.Pixels property should be not null");

 AssertIsTrue(rasterImage.Pixels.Length == 100, "rasterImage.Pixels property should contain exactly 100 items");

 AssertIsTrue((uint) rasterImage.Pixels[99] == 0xFFB21616, "rasterImage.Pixels[99] should be 0xFFB21616");

 AssertIsTrue((uint) rasterImage.Pixels[19] == 0xFF00FF00, "rasterImage.Pixels[19] should be 0xFF00FF00");

 AssertIsTrue((uint) rasterImage.Pixels[10] == 0xFF01FD00, "rasterImage.Pixels[10] should be 0xFF01FD00");

 AssertIsTrue((uint) rasterImage.Pixels[0] == 0xFF0000FF, "rasterImage.Pixels[0] should be 0xFF0000FF");

 AssertIsTrue(Math.Abs(0.999875 - rasterImage.Width) < DefaultTolerance, "rasterImage.Width should be 0.99987");

 AssertIsTrue(Math.Abs(0.999875 - rasterImage.Height) < DefaultTolerance, "rasterImage.Height should be 0.99987");

 AssertIsTrue(Math.Abs(387 - rasterImage.OffsetX) < DefaultTolerance, "rasterImage.OffsetX should be 387");

 AssertIsTrue(Math.Abs(379 - rasterImage.OffsetY) < DefaultTolerance, "rasterImage.OffsetY should be 379");

 AssertIsTrue(Math.Abs(0 - rasterImage.Angle) < DefaultTolerance, "rasterImage.Angle should be 0");

 AssertIsTrue(Math.Abs(0 - rasterImage.LeftBottomShift) < DefaultTolerance, "rasterImage.LeftBottomShift should be 0");

 AssertIsTrue(Math.Abs(0 - rasterImage.ImageRectangle.X) < DefaultTolerance, "rasterImage.ImageRectangle.X should be 0");

 AssertIsTrue(Math.Abs(0 - rasterImage.ImageRectangle.Y) < DefaultTolerance, "rasterImage.ImageRectangle.Y should be 0");

 AssertIsTrue(Math.Abs(10 - rasterImage.ImageRectangle.Width) < DefaultTolerance, "rasterImage.ImageRectangle.Width should be 10");

 AssertIsTrue(Math.Abs(10 - rasterImage.ImageRectangle.Height) < DefaultTolerance, "rasterImage.ImageRectangle.Height should be 10");

}

PSDNET-225. 获取文本图层内联格式的属性

     using (var psdImage = (PsdImage)Image.Load("inline_formatting.psd"))

            {

                List<ITextPortion> regularText = new List<ITextPortion>();

                List<ITextPortion> boldText = new List<ITextPortion>();

                List<ITextPortion> italicText = new List<ITextPortion>();

                var layers = psdImage.Layers;

                for (int index = 0; index < layers.Length; index++)

                {

                    var layer = layers[index];

                    if (!(layer is TextLayer))

                    {

                        continue;

                    }

                    var textLayer = (TextLayer)layer;

                    // gets fonts that contains in text layer

                    var fonts = textLayer.GetFonts();

                    var textPortions = textLayer.TextData.Items;

                    foreach (var textPortion in textPortions)

                    {

                        TextFontInfo font = fonts[textPortion.Style.FontIndex];

                        if (font != null)

                        {

                            switch (font.Style)

                            {

                                case FontStyle.Regular:

                                    regularText.Add(textPortion);

                                    break;

                                case FontStyle.Bold:

                                    boldText.Add(textPortion);

                                    break;

                                case FontStyle.Italic:

                                    italicText.Add(textPortion);

                                    break;

                                default:

                                    throw new ArgumentOutOfRangeException();

                            }

                        }

                    }

                }

            }

PSDNET-214. 如果 PSD 包含图层效果和调整图层,则导出到其他格式时会出现错误

     var loadOptions = new PsdLoadOptions();

   loadOptions.LoadEffectsResource = true;

   using (var image = (PsdImage)Image.Load("clip_shadow.psd", loadOptions))

   {

       image.Save("output.png", new PngOptions());

   }