Aspose.PSD for .NET 19.9 - 发行说明
Contents
[
Hide
]
此页面包含 Aspose.PSD for .NET 19.9 的发行说明
关键 | 摘要 | 类别 |
---|---|---|
PSDNET-160 | 提取错误的图层名称 | 功能 |
PSDNET-175 | 从 PSD TextLayer 中的不同文本部分获取文本属性 | 功能 |
PSDNET-190 | 支持添加图层组 | 功能 |
PSDNET-192 | 支持渐变填充图层的比例属性 | 功能 |
PSDNET-162 | 调整亮度 | 增强 |
PSDNET-174 | 将 PSD 图像保存为 JPEG 时出现 IndexOutOfRangeException | 错误 |
PSDNET-180 | 更新文本图层文本会引发异常 | 错误 |
PSDNET-182 | 旋转翻转操作后保存 PSD 图像会产生无法打开的损坏文件 | 错误 |
公共 API 更改
已添加的 API:
- M:Aspose.PSD.FileFormats.Psd.Layers.LayerGroup.AddLayerGroup(System.String,System.Int32)
- T:Aspose.PSD.FileFormats.Psd.Layers.Text.IText
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.Items
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.Text
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.ProducePortion
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.AddPortion(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion)
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.InsertPortion(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion,System.Int32)
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.RemovePortion(System.Int32)
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.IText.UpdateLayerData
- T:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.Justification
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.FirstLineIndent
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.StartIndent
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.EndIndent
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.SpaceBefore
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.SpaceAfter
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.AutoHyphenate
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.HyphenatedWordSize
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.PreHyphen
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.PostHyphen
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.ConsecutiveHyphens
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.Zone
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.WordSpacing
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.LetterSpacing
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.GlyphSpacing
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.AutoLeading
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.LeadingType
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.Hanging
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.Burasagari
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.KinsokuOrder
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.EveryLineComposer
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.Apply(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph)
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph.IsEqual(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextParagraph)
- T:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion.Text
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion.Style
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextPortion.Paragraph
- T:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.FontSize
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.AutoLeading
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.Leading
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.Tracking
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.Kerning
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.FillColor
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.StrokeColor
- P:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.HindiNumbers
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.Apply(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle)
- M:Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle.IsEqual(Aspose.PSD.FileFormats.Psd.Layers.Text.ITextStyle)
- P:Aspose.PSD.FileFormats.Psd.Layers.TextLayer.TextData
- P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IGradientFillSettings.Scale
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.GdFlResource.Scale
- P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.GradientFillSettings.Scale
已删除的 API:
- 无
用法示例:
PSDNET-160. 提取错误的图层名称
要正确显示图层名称,请使用 DisplayName 属性。 现在为此属性添加了 setter,并且可以修改属性。 当 Photoshop 使用 Name 属性保存图层名称时,韩文字符将存储为 ASCII 中的字节 63'?'。请使用 DisplayName 属性,因为 Name 属性不支持韩文字符。
// 更改图层名称并保存
using (var image = (PsdImage)Image.Load("layers with names.psd"))
{
for (int i = 0; i < image.Layers.Length; i++)
{
var layer = image.Layers[i];
// 设置 DisplayName 属性的新值
layer.DisplayName += "_changed";
}
image.Save("output.psd");
}
PSDNET-175. 从 PSD TextLayer 中的不同文本部分获取文本属性
const double Tolerance = 0.0001;
var filePath = "ThreeColorsParagraphs.psd";
var outputPath = "ThreeColorsParagraph_out.psd";
using (var im = (PsdImage)Image.Load(filePath))
{
for (int i = 0; i < im.Layers.Length; i++)
{
var layer = im.Layers[i] as TextLayer;
if (layer != null)
{
var portions = layer.TextData.Items;
if (portions.Length != 4)
{
throw new Exception();
}
// 检查每个部分的文本
if (portions[0].Text != "Old " ||
portions[1].Text != "color" ||
portions[2].Text != " text\r" ||
portions[3].Text != "Second paragraph\r")
{
throw new Exception();
}
// 检查段落数据
// 段落具有不同的对齐方式
if (
portions[0].Paragraph.Justification != 0 ||
portions[1].Paragraph.Justification != 0 ||
portions[2].Paragraph.Justification != 0 ||
portions[3].Paragraph.Justification != 2)
{
throw new Exception();
}
// 第一和第二段的所有其他属性相等
for (int j = 0; j < portions.Length; j++)
{
var paragraph = portions[j].Paragraph;
if (Math.Abs(paragraph.AutoLeading - 1.2) > Tolerance ||
paragraph.AutoHyphenate != false ||
paragraph.Burasagari != false ||
paragraph.ConsecutiveHyphens != 8 ||
Math.Abs(paragraph.StartIndent) > Tolerance ||
Math.Abs(paragraph.EndIndent) > Tolerance ||
paragraph.EveryLineComposer != false ||
Math.Abs(paragraph.FirstLineIndent) > Tolerance ||
paragraph.GlyphSpacing.Length != 3 ||
Math.Abs(paragraph.GlyphSpacing[0] - 1) > Tolerance ||
Math.Abs(paragraph.GlyphSpacing[1] - 1) > Tolerance ||
Math.Abs(paragraph.GlyphSpacing[2] - 1) > Tolerance ||
paragraph.Hanging != false ||
paragraph.HyphenatedWordSize != 6 ||
paragraph.KinsokuOrder != 0 ||
paragraph.LetterSpacing.Length != 3 ||
Math.Abs(paragraph.LetterSpacing[0]) > Tolerance ||
Math.Abs(paragraph.LetterSpacing[1]) > Tolerance ||
Math.Abs(paragraph.LetterSpacing[2]) > Tolerance ||
paragraph.LeadingType != LeadingMode.Auto ||
paragraph.PreHyphen != 2 ||
paragraph.PostHyphen != 2 ||
Math.Abs(paragraph.SpaceBefore) > Tolerance ||
Math.Abs(paragraph.SpaceAfter) > Tolerance ||
paragraph.WordSpacing.Length != 3 ||
Math.Abs(paragraph.WordSpacing[0] - 0.8) > Tolerance ||
Math.Abs(paragraph.WordSpacing[1] - 1.0) > Tolerance ||
Math.Abs(paragraph.WordSpacing[2] - 1.33) > Tolerance ||
Math.Abs(paragraph.Zone - 36.0) > Tolerance)
{
throw new Exception();
}
}
// 检查样式数据
// 样式具有不同的颜色和字体大小
if (Math.Abs(portions[0].Style.FontSize - 12) > Tolerance ||
Math.Abs(portions[1].Style.FontSize - 12) > Tolerance ||
Math.Abs(portions[2].Style.FontSize - 12) > Tolerance ||
Math.Abs(portions[3].Style.FontSize - 10) > Tolerance)
{
throw new Exception();
}
if (portions[0].Style.FillColor != Color.FromArgb(255, 145, 0, 0) ||
portions[1].Style.FillColor != Color.FromArgb(255, 201, 128, 2) ||
portions[2].Style.FillColor != Color.FromArgb(255, 18, 143, 4) ||
portions[3].Style.FillColor != Color.FromArgb(255, 145, 42, 100))
{
throw new Exception();
}
for (int j = 0; j < portions.Length; j++)
{
var style = portions[j].Style;
if (style.AutoLeading != false ||
style.HindiNumbers != false ||
style.Kerning != 0 ||
style.Leading != 0 ||
style.StrokeColor != Color.FromArgb(255, 175, 90, 163) ||
style.Tracking != 50)
{
throw new Exception();
}
}
// 文本编辑示例
portions[0].Text = "Hello ";
portions[1].Text = "World";
// 删除文本部分的示例
layer.TextData.RemovePortion(3);
layer.TextData.RemovePortion(2);
// 添加新文本部分的示例
var createdPortion = layer.TextData.ProducePortion();
createdPortion.Text = "!!!\r";
layer.TextData.AddPortion(createdPortion);
portions = layer.TextData.Items;
// 段的编辑示例和样式
// 设置正确的对齐方式
portions[0].Paragraph.Justification = 1;
portions[1].Paragraph.Justification = 1;
portions[2].Paragraph.Justification = 1;
// 每种样式的不同颜色。 颜色将更改,但完全支持渲染
portions[0].Style.FillColor = Color.Aquamarine;
portions[1].Style.FillColor = Color.Violet;
portions[2].Style.FillColor = Color.LightBlue;
// 不同字体。 将被更改,但渲染不完全受支持
portions[0].Style.FontSize = 6;
portions[1].Style.FontSize = 8;
portions[2].Style.FontSize = 10;
layer.TextData.UpdateLayerData();
im.Save(outputPath, new PsdOptions(im));
break;
}
}
}
PSDNET-190. 支持添加图层组
// -Group 1
// --Layer 1
// --Group 2
// ---Layer 2
// ---Layer 3
// --Layer 4
string dataDir = "psdnet190_test.psd";
var createOptions = new PsdOptions();
createOptions.Source = new FileCreateSource(dataDir, false);
createOptions.Palette = new PsdColorPalette(new Color[] { Color.Green });
using (var psdImage = (PsdImage)Image.Create(createOptions, 500, 500))
{
LayerGroup group1 = psdImage.AddLayerGroup("Group 1", 0, true);
Layer layer1 = new Layer(psdImage);
layer1.Name = "Layer 1";
group1.AddLayer(layer1);
LayerGroup group2 = group1.AddLayerGroup("Group 2", 1);
Layer layer2 = new Layer(psdImage);
layer2.Name = "Layer 2";
group2.AddLayer(layer2);
Layer layer3 = new Layer(psdImage);
layer3.Name = "Layer 3";
group2.AddLayer(layer3);
Layer layer4 = new Layer(psdImage);
layer4.Name = "Layer 4";
group1.AddLayer(layer4);
psdImage.Save();
}
PSDNET-192. 支持渐变填充图层的比例属性
using (var image = (PsdImage)Image.Load("FillLayerGradient.psd"))
{
// 获取填充图层
FillLayer fillLayer = null;
foreach (var layer in image.Layers)
{
fillLayer = layer as FillLayer;
if (fillLayer != null)
{
break;
}
}
var settings = fillLayer.FillSettings as IGradientFillSettings;
// 更新比例值
settings.Scale = 200;
fillLayer.Update(); // 更新像素数据
image.Save("scaledImage.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
PSDNET-174. 将 PSD 图像保存为 JPEG 时出现 IndexOutOfRangeException
using (var image = Aspose.PSD.Image.Load("SamplePSD.psd"))
{
image.Save("sampleJPG.jpg", new JpegOptions());
}
PSDNET-180. 更新文本图层文本会引发异常
// 更新文本图层文本会引发异常
string filePath = "FlipVertical.psd";
string outputPath = "FlipVertical_changed.psd";
var newText = "Test";
using (var image = Image.Load(filePath))
{
var psdImage = image as PsdImage;
if (image == null)
{
return;
}
var layers = psdImage.Layers;
for (var index = layers.Length - 1; index >= 0; index--)
{
var layer = layers[index] as TextLayer;
if (layer == null)
{
continue;
}
layer.UpdateText(newText);
}
var imageOptions = new PsdOptions(psdImage);
psdImage.Save(outputPath, imageOptions);
}
PSDNET-182. 保存 PSD 图像后进行 RotateFlip 操作会生成无法打开的损坏文件
string sourceFileName = "1.psd";
RotateFlipType flipType = RotateFlipType.Rotate270FlipXY;
string outFileNamePsd = "RotateFlipTest2617.psd";
using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
{
image.RotateFlip(flipType);
image.Save(outFileNamePsd);
}