原創|產品更新|編輯:李顯亮|2020-12-03 09:48:35.263|閱讀 334 次
概述:Aspose.PSD for .Net更新至新版本v20.11,增加了在PSD圖像中復制智能對象層的功能,修復無法加載Psd等問題,歡迎下載體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.PSD for .Net是高級PSD和入門級AI文件格式操作API,允許創建和編輯Photoshop文件,并提供更新圖層屬性,添加水印,執行圖形操作或將一種文件格式轉換為另一種文件的功能,沒有任何Adobe Photoshop或Adobe Illustrator依賴項。
Aspose.PSD for .Net更新至新版本v20.11,增加了在PSD圖像中復制智能對象層的功能,修復無法加載Psd等問題。
>>你可以點擊這里下載Aspose.PSD for .NET v20.11測試體驗。(安裝包僅提供部分功能,并設置限制,如需試用完整功能請)
key | 概述 | 類別 |
---|---|---|
PSDNET-713 | 果不將PSD保存為文件,Aspose.PSD不能將PSD轉換為其他顏色模式/ BitDepth | 新功能 |
PSDNET-754 | 增加了在PSD圖像中復制智能對象層的功能 | 新功能 |
PSDNET-267 | 帶有圖層效果加載和保存PSD文件的異常 | Bug修復 |
PSDNET-579 | 方法“ Image.LoadRawData”拋出NullPointer異常 | Bug修復 |
PSDNET-741 | 嘗試打開文件時拋出ImageLoadException | Bug修復 |
PSDNET-744 | Aspose.PSD 20.10:無法加載Psd | Bug修復 |
PSDNET-754——增加了在PSD圖像中復制智能對象層的功能
string dataDir = "PSDNET754_1\\"; string outputDir = dataDir + "output\\"; // These examples demonstrate how to copy smart object layers in a PSD image. ExampleOfCopingSmartObjectLayer("r-embedded-psd"); ExampleOfCopingSmartObjectLayer("r-embedded-png"); ExampleOfCopingSmartObjectLayer("r-embedded-transform"); ExampleOfCopingSmartObjectLayer("new_panama-papers-8-trans4"); void ExampleOfCopingSmartObjectLayer(string fileName) { int layerNumber = 0; // The layer number to copy string filePath = dataDir + fileName + ".psd"; string outputFilePath = outputDir + fileName + "_copy_" + layerNumber; string pngOutputPath = outputFilePath + ".png"; string psdOutputPath = outputFilePath + ".psd"; using (PsdImage image = (PsdImage)Image.Load(filePath)) { var smartObjectLayer = (SmartObjectLayer)image.Layers[layerNumber]; var newLayer = smartObjectLayer.NewSmartObjectViaCopy(); newLayer.IsVisible = false; AssertIsTrue(object.ReferenceEquals(newLayer, image.Layers[layerNumber + 1])); AssertIsTrue(object.ReferenceEquals(smartObjectLayer, image.Layers[layerNumber])); var duplicatedLayer = smartObjectLayer.DuplicateLayer(); duplicatedLayer.DisplayName = smartObjectLayer.DisplayName + " shared image"; AssertIsTrue(object.ReferenceEquals(newLayer, image.Layers[layerNumber + 2])); AssertIsTrue(object.ReferenceEquals(duplicatedLayer, image.Layers[layerNumber + 1])); AssertIsTrue(object.ReferenceEquals(smartObjectLayer, image.Layers[layerNumber])); using (var innerImage = (RasterImage)smartObjectLayer.LoadContents(null)) { // Let's invert the embedded smart object image (for an inner PSD image we invert only its first layer) InvertImage(innerImage); // Let's replace the embedded smart object image in the PSD layer smartObjectLayer.ReplaceContents(innerImage); } // The duplicated layer shares its imbedded image with the original smart object // and it should be updated explicitly otherwise its rendering cache remains unchanged. // We update every smart object to make sure that the new layer created by NewSmartObjectViaCopy // does not share the embedded image with the others. image.SmartObjectProvider.UpdateAllModifiedContent(); image.Save(pngOutputPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }); image.Save(psdOutputPath, new PsdOptions(image)); } } // Inverts the raster image including the PSD image. void InvertImage(RasterImage innerImage) { var innerPsdImage = innerImage as PsdImage; if (innerPsdImage != null) { InvertRasterImage(innerPsdImage.Layers[0]); } else { InvertRasterImage(innerImage); } } // Inverts the raster image. void InvertRasterImage(RasterImage innerImage) { var pixels = innerImage.LoadArgb32Pixels(innerImage.Bounds); for (int i = 0; i < pixels.Length; i++) { var pixel = pixels[i]; var alpha = (int)(pixel & 0xff000000); pixels[i] = (~(pixel & 0x00ffffff)) | alpha; } innerImage.SaveArgb32Pixels(innerImage.Bounds, pixels); } void AssertIsTrue(bool condition) { if (!condition) { throw new FormatException(string.Format("Expected true")); } }
PSDNET-713——如果不將PSD保存為文件,Aspose.PSD不能將PSD轉換為其他顏色模式/ BitDepth
string dataDir = "PSDNET713_1\\"; string outputDir = dataDir + "output\\"; // These examples demonstrate conversion of the PSD image format to other Color Modes/BitDepth. ImageConversion(ColorModes.Grayscale, 16, 2); ImageConversion(ColorModes.Grayscale, 8, 2); ImageConversion(ColorModes.Grayscale, 8, 1); ImageConversion(ColorModes.Rgb, 8, 4); ImageConversion(ColorModes.Rgb, 16, 4); ImageConversion(ColorModes.Cmyk, 8, 5); ImageConversion(ColorModes.Cmyk, 16, 5); void ImageConversion(ColorModes colorMode, short channelBitsCount, short channelsCount) { var compression = channelBitsCount > 8 ? CompressionMethod.Raw : CompressionMethod.RLE; SaveToPsdThenLoadAndSaveToPng( "SheetColorHighlightExample", colorMode, channelBitsCount, channelsCount, compression, 1); SaveToPsdThenLoadAndSaveToPng( "FillOpacitySample", colorMode, channelBitsCount, channelsCount, compression, 2); SaveToPsdThenLoadAndSaveToPng( "ClippingMaskRegular", colorMode, channelBitsCount, channelsCount, compression, 3); } // Saves to PSD then loads the saved file and saves to PNG. void SaveToPsdThenLoadAndSaveToPng( string file, ColorModes colorMode, short channelBitsCount, short channelsCount, CompressionMethod compression, int layerNumber) { string srcFile = dataDir + file + ".psd"; string postfix = colorMode.ToString() + channelBitsCount + "bits" + channelsCount + "channels" + compression; string fileName = file + "_" + postfix + ".psd"; string exportPath = outputDir + fileName; PsdOptions psdOptions = new PsdOptions() { ColorMode = colorMode, ChannelBitsCount = channelBitsCount, ChannelsCount = channelsCount, CompressionMethod = compression }; using (var image = (PsdImage)Image.Load(srcFile)) { image.Convert(psdOptions); RasterCachedImage raster = image.Layers.Length > 0 && layerNumber >= 0 ? (RasterCachedImage)image.Layers[layerNumber] : image; Aspose.PSD.Graphics graphics = new Graphics(raster); int width = raster.Width; int height = raster.Height; Rectangle rect = new Rectangle( width / 3, height / 3, width - (2 * (width / 3)) - 1, height - (2 * (height / 3)) - 1); graphics.DrawRectangle(new Aspose.PSD.Pen(Color.DarkGray, 1), rect); image.Save(exportPath); } string pngExportPath = Path.ChangeExtension(exportPath, "png"); using (PsdImage image = (PsdImage)Image.Load(exportPath)) { image.Save(pngExportPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }); } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn