彩票走势图

PSD文件处理API-Aspose.PSD v20.4九大新功能全新上线!功能演示带你快速上手!

原创|产品更新|编辑:李显亮|2020-04-28 10:18:11.390|阅读 230 次

概述:.NET版Aspose.PSD迎来了4月的最新更新!新增了如下九大新功能:支持“向量原始数据”资源、支持lclrResource(工作表颜色设置)、LengthRecord数据中的支持属性、支持图像部分资源#1010背景颜色、在运行时添加填充层,支持图像部分资源#1009边框信息、支持AI格式文件中的图层、支持读取和编辑渐变叠加层效果、渐变叠加层效果的渲染 。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

Aspose.PSD for .Net是高级PSD和入门级AI文件格式操作API,允许创建和编辑Photoshop文件,并提供更新图层属性,添加水印,执行图形操作或将一种文件格式转换为另一种文件的功能,没有任何Adobe Photoshop或Adobe Illustrator依赖项。

令人兴奋的是,.NET版Aspose.PSD迎来了4月的最新更新!新增了如下六大新功能:

  • 支持“向量原始数据”资源
  • 支持lclrResource(工作表颜色设置)
  • LengthRecord数据中的支持属性。(路径操作(布尔操作),层中形状的索引,贝塞尔结记录的计数)
  • 支持图像部分资源#1010背景颜色
  • 在运行时添加填充层
  • 支持图像部分资源#1009边框信息
  • 支持AI格式文件中的图层
  • 支持读取和编辑渐变叠加层效果
  • 支持渐变叠加层效果的渲染

>>你可以点击这里下载Aspose.PSD for .NET v20.4测试体验


具体更新内容

key 概述 类别
PSDNET-567 支持“向量原始数据”资源 新功能
PSDNET-373 支持lclrResource(工作表颜色设置) 新功能
PSDNET-563 LengthRecord数据中的支持属性。(路径操作(布尔操作),层中形状的索引,贝塞尔结记录的计数) 新功能
PSDNET-425 支持图像部分资源#1010背景颜色 新功能
PSDNET-530 在运行时添加填充层 新功能
PSDNET-424 支持图像部分资源#1009边框信息 新功能
PSDNET-592 支持AI格式文件中的图层 新功能
PSDNET-256 支持读取和编辑渐变叠加层效果 新功能
PSDNET-257 渐变叠加层效果的渲染 新功能
PSDNET-585 GradientOverlayEffect.BlendMode属性更改不会在Photoshop中显示 Bug修复
PSDNET-561 修复了使用灰度ColorMode和每通道16位将PSD图像保存为灰度PSD格式的问题 Bug修复
PSDNET-560 修复了使用灰度ColorMode和每通道16位将PSD图像保存为PNG格式的问题 Bug修复

PSDNET-567 支持“向量原始数据”资源

// VogkResource Support
static void ExampleOfVogkResourceSupport()
{
    string fileName = "VectorOriginationDataResource.psd";
    string outFileName = "out_VectorOriginationDataResource_.psd";
 
    using (var psdImage = (PsdImage)Image.Load(fileName))
    {
        var resource = GetVogkResource(psdImage);
 
        // Reading
        if (resource.ShapeOriginSettings.Length != 1 ||
            !resource.ShapeOriginSettings[0].IsShapeInvalidated ||
            resource.ShapeOriginSettings[0].OriginIndex != 0)
        {
            throw new Exception("VogkResource were read wrong.");
        }
 
        // Editing
        resource.ShapeOriginSettings = new[]
        {
            resource.ShapeOriginSettings[0],
            new VectorShapeOriginSettings(true, 1)
        };
 
        psdImage.Save(outFileName);
    }
}
 
static VogkResource GetVogkResource(PsdImage image)
{
    var layer = image.Layers[1];
 
    VogkResource resource = null;
    var resources = layer.Resources;
    for (int i = 0; i < resources.Length; i++) { if (resources[i] is VogkResource) { resource = (VogkResource)resources[i]; break; } } if (resource == null) { throw new Exception("VogkResourcenot found."); } return resource; }

PSDNET-373 支持lclrResource(工作表颜色设置)

static void CheckSheetColorsAndRerverse(SheetColorHighlightEnum[] sheetColors, PsdImage img)
{
    int layersCount = img.Layers.Length;
    for (int layerIndex = 0; layerIndex < layersCount; layerIndex++) { Layer layer = img.Layers[layerIndex]; LayerResource[] resources = layer.Resources; foreach (LayerResource layerResource in resources) { // The lcrl resource always presents in psd file resource list. LclrResource resource = layerResource as LclrResource; if (resource != null) { if (resource.Color != sheetColors[layerIndex]) { throw new Exception("Sheet Color has been read wrong"); } // Reverse of style sheet colors. Set up of Layer color highlight. resource.Color = sheetColors[layersCount - layerIndex - 1]; break; } } } } string sourceFilePath = "AllLclrResourceColors.psd"; string outputFilePath = "AllLclrResourceColorsReversed.psd"; // In the file colors of layers' highlighting are in this order SheetColorHighlightEnum[] sheetColors = new SheetColorHighlightEnum[] { SheetColorHighlightEnum.Red, SheetColorHighlightEnum.Orange, SheetColorHighlightEnum.Yellow, SheetColorHighlightEnum.Green, SheetColorHighlightEnum.Blue, SheetColorHighlightEnum.Violet, SheetColorHighlightEnum.Gray, SheetColorHighlightEnum.NoColor }; // Layer Sheet Color is used to visually highlight layers. // For example you can update some layers in PSD and then highlight by color the layer which you want to attract attention. using (PsdImage img = (PsdImage)Image.Load(sourceFilePath)) { CheckSheetColorsAndRerverse(sheetColors, img); img.Save(outputFilePath, new PsdOptions()); } using (PsdImage img = (PsdImage)Image.Load(outputFilePath)) { // Colors should be reversed Array.Reverse(sheetColors); CheckSheetColorsAndRerverse(sheetColors, img); }

PSDNET-563 LengthRecord数据中的支持属性。(路径操作(布尔操作),层中形状的索引,贝塞尔结记录的计数)

string fileName = "PathOperationsShape.psd";
 using (var im = (PsdImage)Image.Load(fileName))
 {
     VsmsResource resource = null;
     foreach (var layerResource in im.Layers[1].Resources)
     {
         if (layerResource is VsmsResource)
         {
             resource = (VsmsResource)layerResource;
             break;
         }
     }
 
     LengthRecord lengthRecord0 = (LengthRecord)resource.Paths[2];
     LengthRecord lengthRecord1 = (LengthRecord)resource.Paths[7];
     LengthRecord lengthRecord2 = (LengthRecord)resource.Paths[11];
 
     // Here we changin the way to combining betwen shapes.
     lengthRecord0.PathOperations = PathOperations.ExcludeOverlappingShapes;
     lengthRecord1.PathOperations = PathOperations.IntersectShapeAreas;
     lengthRecord2.PathOperations = PathOperations.SubtractFrontShape;
 
     im.Save("out_" + fileName);
 }

PSDNET-425 支持图像部分资源#1010背景颜色

string sourceFile = "input.psd";
string outputFile = "output.psd";
 
using (var image = (PsdImage)Image.Load(sourceFile))
{
    ResourceBlock[] imageResources = image.ImageResources;
    BackgroundColorResource backgroundColorResource = null;
    foreach (var imageResource in imageResources)
    {
        if (imageResource is BackgroundColorResource)
        {
            backgroundColorResource = (BackgroundColorResource)imageResource;
            break;
        }
    }
 
    // update BackgroundColorResource
    backgroundColorResource .Color = Color.DarkRed;
 
    image.Save(outputFile);
}

PSDNET-530 在运行时添加填充层

string outputPsd = "output.psd";
 
using (var image = new PsdImage(100, 100))
{
    FillLayer colorFillLayer = FillLayer.CreateInstance(FillType.Color);
    colorFillLayer.DisplayName = "Color Fill Layer";
    image.AddLayer(colorFillLayer);
 
    FillLayer gradientFillLayer = FillLayer.CreateInstance(FillType.Gradient);
    gradientFillLayer.DisplayName = "Gradient Fill Layer";
    image.AddLayer(gradientFillLayer);
 
    FillLayer patternFillLayer = FillLayer.CreateInstance(FillType.Pattern);
    patternFillLayer.DisplayName = "Pattern Fill Layer";
    patternFillLayer.Opacity = 50;
    image.AddLayer(patternFillLayer);
 
    image.Save(outputPsd);
}

PSDNET-424 支持图像部分资源#1009边框信息

string sourceFile = "input.psd";
string outputFile = "output.psd";
 
using (var image = (PsdImage)Image.Load(sourceFile))
{
    ResourceBlock[] imageResources = image.ImageResources;
    BorderInformationResource borderInfoResource = null;
    foreach (var imageResource in imageResources)
    {
        if (imageResource is BorderInformationResource)
        {
            borderInfoResource = (BorderInformationResource)imageResource;
            break;
        }
    }
 
    // update BorderInformationResource
    borderInfoResource.Width = 0.1;
    borderInfoResource.Unit = PhysicalUnit.Inches;
 
    image.Save(outputFile);
}

PSDNET-592 支持AI格式文件中的图层

void AssertIsTrue(bool condition, string message)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}
 
string sourceFileName = "form_8_2l3_7.ai";
string outputFileName = "form_8_2l3_7_export";
using (AiImage image = (AiImage)Image.Load(sourceFileName))
{
    AiLayerSection layer0 = image.Layers[0];
    AssertIsTrue(layer0 != null, "Layer 0 should be not null.");
    AssertIsTrue(layer0.Name == "Layer 4", "The Name property of the layer 0 should be `Layer 4`");
    AssertIsTrue(!layer0.IsTemplate, "The IsTemplate property of the layer 0 should be false.");
    AssertIsTrue(layer0.IsLocked, "The IsLocked property of the layer 0 should be true.");
    AssertIsTrue(layer0.IsShown, "The IsShown property of the layer 0 should be true.");
    AssertIsTrue(layer0.IsPrinted, "The IsPrinted property of the layer 0 should be true.");
    AssertIsTrue(!layer0.IsPreview, "The IsPreview property of the layer 0 should be false.");
    AssertIsTrue(layer0.IsImagesDimmed, "The IsImagesDimmed property of the layer 0 should be true.");
    AssertIsTrue(layer0.DimValue == 51, "The DimValue property of the layer 0 should be 51.");
    AssertIsTrue(layer0.ColorNumber == 0, "The ColorNumber property of the layer 0 should be 0.");
    AssertIsTrue(layer0.Red == 79, "The Red property of the layer 0 should be 79.");
    AssertIsTrue(layer0.Green == 128, "The Green property of the layer 0 should be 128.");
    AssertIsTrue(layer0.Blue == 255, "The Blue property of the layer 0 should be 255.");
    AssertIsTrue(layer0.RasterImages.Length == 0, "The pixels length property of the raster image in the layer 0 should equals 0.");
 
    AiLayerSection layer1 = image.Layers[1];
    AssertIsTrue(layer1 != null, "Layer 1 should be not null.");
    AssertIsTrue(layer1.Name == "Layer 1", "The Name property of the layer 1 should be `Layer 1`");
    AssertIsTrue(layer1.RasterImages.Length == 1, "The length property of the raster images in the layer 1 should equals 1.");
 
    AiRasterImageSection rasterImage = layer1.RasterImages[0];
    AssertIsTrue(rasterImage != null, "The raster image in the layer 1 should be not null.");
    AssertIsTrue(rasterImage.Pixels != null, "The pixels property of the raster image in the layer 1 should be not null.");
    AssertIsTrue(string.Empty == rasterImage.Name, "The Name property of the raster image in the layer 1 should be empty");
    AssertIsTrue(rasterImage.Pixels.Length == 100, "The pixels length property of the raster image in the layer 1 should equals 100.");
 
    image.Save(outputFileName + ".psd", new PsdOptions());
    image.Save(outputFileName + ".png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}

PSDNET-256 支持读取和编辑渐变叠加层效果

// Creates/Gets and edits the gradient overlay effect in a layer.
using (var psdImage = this.LoadFile("psdnet256.psd", new PsdLoadOptions() { LoadEffectsResource = true }))
{
    BlendingOptions layerBlendOptions = psdImage.Layers[1].BlendingOptions;
    GradientOverlayEffect gradientOverlayEffect = null;
 
    // Search GradientOverlayEffect in a layer.
    foreach (ILayerEffect effect in layerBlendOptions.Effects)
    {
        gradientOverlayEffect = effect as GradientOverlayEffect;
        if (gradientOverlayEffect != null)
        {
            break;
        }
    }
 
    if (gradientOverlayEffect == null)
    {
        // You can create a new GradientOverlayEffect if it not exists.
        gradientOverlayEffect = layerBlendOptions.AddGradientOverlay();
    }
 
    // Add a bit of transparency to the effect.
    gradientOverlayEffect.Opacity = 200;
 
    // Change the blend mode of gradient effect.
    gradientOverlayEffect.BlendMode = BlendMode.Hue;
 
    // Gets GradientFillSettings object to configure gradient overlay settings.
    GradientFillSettings settings = gradientOverlayEffect.Settings;
 
    // Setting a new gradient with two colors.
    settings.ColorPoints = new IGradientColorPoint[]
    {
        new GradientColorPoint(Color.GreenYellow, 0, 50),
        new GradientColorPoint(Color.BlueViolet, 4096, 50),
    };
 
    // Sets an inclination of the gradient at an angle of 80 degrees.
    settings.Angle = 80;
 
    // Scale gradient effect up to 150%.
    settings.Scale = 150;
 
    // Sets type of gradient.
    settings.GradientType = GradientType.Linear;
 
    // Make the gradient opaque by setting the opacity to 100% at each transparency point.
    settings.TransparencyPoints[0].Opacity = 100;
    settings.TransparencyPoints[1].Opacity = 100;
 
    psdImage.Save("psdnet256.psd_output.psd");
}

PSDNET-257 渐变叠加层效果的渲染

string srcFile = "gradientOverlayEffect.psd";
string outputPng = "output.png";
string outputPsd = "output.psd";
 
using (var psdImage = (PsdImage)Image.Load(srcFile, new PsdLoadOptions() { LoadEffectsResource = true }))
{
    psdImage.Save(outputPng, new PngOptions());
    psdImage.Save(outputPsd);
}


还想要更多吗?您可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时,我们很高兴为您提供查询和咨询
标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP