internal static BitmapLayer DecodeToPdnLayer( this PhotoshopFile.Layer psdLayer) { var psdFile = psdLayer.PsdFile; psdLayer.CreateMissingChannels(); var pdnLayer = new BitmapLayer(psdFile.ColumnCount, psdFile.RowCount); pdnLayer.Name = psdLayer.Name; pdnLayer.Opacity = psdLayer.Opacity; pdnLayer.Visible = psdLayer.Visible; ImageDecoderPdn.DecodeImage(pdnLayer, psdLayer); return(pdnLayer); }
public static Document Load(System.IO.Stream input) { // Load and decompress Photoshop file structures var loadContext = new LoadContext(); var psdFile = new PsdFile(input, loadContext); // Multichannel images are loaded by processing each channel as a // grayscale layer. if (psdFile.ColorMode == PsdColorMode.Multichannel) { CreateLayersFromChannels(psdFile); psdFile.ColorMode = PsdColorMode.Grayscale; } // Convert into Paint.NET internal representation var document = new Document(psdFile.ColumnCount, psdFile.RowCount); if (psdFile.Layers.Count == 0) { psdFile.BaseLayer.CreateMissingChannels(); var layer = Layer.CreateBackgroundLayer(psdFile.ColumnCount, psdFile.RowCount); ImageDecoderPdn.DecodeImage(layer, psdFile.BaseLayer); document.Layers.Add(layer); } else { psdFile.VerifyLayerSections(); ApplyLayerSections(psdFile.Layers); var pdnLayers = psdFile.Layers.AsParallel().AsOrdered() .Select(psdLayer => psdLayer.DecodeToPdnLayer()) .ToList(); document.Layers.AddRange(pdnLayers); } return(document); }