├── .gitignore
├── .gitmodules
├── LICENSE.md
├── Ntreev.Library.Psd.AssemblyInfo
├── AssemblyInfo.cs
├── Ntreev.Library.Psd.AssemblyInfo.projitems
└── Ntreev.Library.Psd.AssemblyInfo.shproj
├── Ntreev.Library.Psd.Sharing
├── Ntreev.Library.Psd.Sharing.projitems
└── Ntreev.Library.Psd.Sharing.shproj
├── Ntreev.Library.Psd
├── AdditionalLayerInformation.cs
├── BlendMode.cs
├── Channel.cs
├── ChannelType.cs
├── ColorMode.cs
├── ColorSpace.cs
├── CompressionType.cs
├── DescriptorStructure.cs
├── EmbeddedLayer.cs
├── Extensions.cs
├── FileHeaderSection.cs
├── IChannel.cs
├── IImageSource.cs
├── ILinkedLayer.cs
├── IProperties.cs
├── IPropertiesExtension.cs
├── IPsdLayer.cs
├── InternalDocument.cs
├── InvalidFormatException.cs
├── LayerBlendingRanges.cs
├── LayerExtraRecords.cs
├── LayerFlags.cs
├── LayerMask.cs
├── LayerRecords.cs
├── LayerandMaskInformationSection.cs
├── LazyProperties.cs
├── LazyValueReader.cs
├── LinkedLayer.cs
├── Ntreev.Library.Psd.csproj
├── PSDReader.cs
├── PathResolver.cs
├── Properties.cs
├── PsdDocument.cs
├── PsdLayer.cs
├── PsdResolver.cs
├── PsdUtility.cs
├── RangeStream.cs
├── Readers
│ ├── ColorModeDataSectionReader.cs
│ ├── EmptyResourceReader.cs
│ ├── FileHeaderSectionReader.cs
│ ├── ImageDataSectionReader.cs
│ ├── ImageResources
│ │ ├── Reader_GridAndGuides.cs
│ │ ├── Reader_ResolutionInfo.cs
│ │ ├── Reader_SlicesInfo.cs
│ │ └── Reader_VersionInfo.cs
│ ├── ImageResourcesSectionReader.cs
│ ├── LayerAndMaskInformation
│ │ ├── ChannelsReader.cs
│ │ ├── DocumentResourceReader.cs
│ │ ├── EmbeddedLayerReader.cs
│ │ ├── GlobalLayerMaskInfoReader.cs
│ │ ├── LayerBlendingRangesReader.cs
│ │ ├── LayerExtraRecordsReader.cs
│ │ ├── LayerInfoReader.cs
│ │ ├── LayerMaskReader.cs
│ │ ├── LayerRecordsReader.cs
│ │ ├── LayerResourceReader.cs
│ │ ├── LinkedDocumentReader.cs
│ │ ├── LinkedDocumnetFileHeaderReader.cs
│ │ └── LinkedLayerReader.cs
│ ├── LayerAndMaskInformationSectionReader.cs
│ ├── LayerResources
│ │ ├── Reader_PlLd.cs
│ │ ├── Reader_SoLE.cs
│ │ ├── Reader_SoLd.cs
│ │ ├── Reader_TySh.cs
│ │ ├── Reader_fxrp.cs
│ │ ├── Reader_iOpa.cs
│ │ ├── Reader_lfx2.cs
│ │ ├── Reader_lnk2.cs
│ │ ├── Reader_lnk3.cs
│ │ ├── Reader_lnkD.cs
│ │ ├── Reader_lnkE.cs
│ │ ├── Reader_lnsr.cs
│ │ ├── Reader_lrFX.cs
│ │ ├── Reader_lsct.cs
│ │ ├── Reader_lsdk.cs
│ │ ├── Reader_luni.cs
│ │ ├── Reader_lyid.cs
│ │ ├── Reader_lyvr.cs
│ │ └── Reader_shmd.cs
│ ├── ReaderCollector.cs
│ └── ResourceReaderBase.cs
├── ResourceIDAttribute.cs
├── SectionType.cs
├── Structures
│ ├── BaseStructure.cs
│ ├── StructureAlias.cs
│ ├── StructureClass.cs
│ ├── StructureEngineData.cs
│ ├── StructureEnumerate.cs
│ ├── StructureEnumerateReference.cs
│ ├── StructureList.cs
│ ├── StructureObjectArray.cs
│ ├── StructureOffset.cs
│ ├── StructureProperty.cs
│ ├── StructureReader.cs
│ ├── StructureReference.cs
│ ├── StructureUnitFloat.cs
│ └── StructureUnknownOSType.cs
├── UnitType.cs
└── ValueReader.cs
├── Ntreev.Library.PsdViewer
├── App.config
├── App.xaml
├── App.xaml.cs
├── AppBootstrapper.cs
├── Controls
│ ├── CellTemplateSelector.cs
│ ├── TreeListView.xaml
│ └── TreeListView.xaml.cs
├── Converters
│ ├── BooleanToVisibilityConverter.cs
│ └── LevelToIndentConverter.cs
├── Dialogs
│ ├── ViewModels
│ │ └── PreviewViewModel.cs
│ └── Views
│ │ ├── PreviewView.xaml
│ │ └── PreviewView.xaml.cs
├── IShell.cs
├── Images
│ ├── export.png
│ ├── image_layer.png
│ ├── linked_layer.png
│ └── ps.png
├── LayerExtension.cs
├── Ntreev.Library.PsdViewer.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ShellView.xaml
├── ShellView.xaml.cs
├── ShellViewModel.cs
├── ViewModels
│ ├── LayerItemViewModel.cs
│ ├── LinkedLayerItemViewModel.cs
│ ├── PSDItemViewModel.cs
│ └── PropertiesItemViewModel.cs
└── packages.config
├── Psd.sln
├── Psd.sln.licenseheader
├── README.md
├── gen-ver.bat
├── gen-ver.ps1
├── packages
└── repositories.config
└── version.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | # git ignore file
2 | bin/
3 | obj/
4 | Debug/
5 | Release/
6 | packages/
7 | *.suo
8 | /.vs
9 | *.bat
10 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NtreevSoft/psd-parser/5866c373d98707d3cbe9fe0616011698b98c85a0/.gitmodules
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2015 Ntreev Soft co., Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd.AssemblyInfo/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | #if DEBUG
3 | [assembly: AssemblyConfiguration("Debug")]
4 | #else
5 | [assembly: AssemblyConfiguration("Release")]
6 | #endif
7 | [assembly: AssemblyCompany("NtreevSoft")]
8 | [assembly: AssemblyCopyright("Copyright © Ntreev Soft 2015")]
9 | [assembly: AssemblyTrademark("")]
10 | [assembly: AssemblyCulture("")]
11 | [assembly: AssemblyVersion("1.1.18306.1005")]
12 | [assembly: AssemblyFileVersion("")]
13 | [assembly: AssemblyInformationalVersion("")]
14 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd.AssemblyInfo/Ntreev.Library.Psd.AssemblyInfo.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 720fdfec-6e43-4663-b378-35ddc17034e0
7 |
8 |
9 | Ntreev.Library.Psd.AssemblyInfo
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd.AssemblyInfo/Ntreev.Library.Psd.AssemblyInfo.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 720fdfec-6e43-4663-b378-35ddc17034e0
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd.Sharing/Ntreev.Library.Psd.Sharing.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 0627dfd8-b163-4d2f-830f-3cc6ee70265b
7 |
8 |
9 | Ntreev.Library.Psd.Sharing
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd.Sharing/Ntreev.Library.Psd.Sharing.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0627dfd8-b163-4d2f-830f-3cc6ee70265b
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/AdditionalLayerInformation.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | class AdditionalLayerInformation
26 | {
27 | public LinkedLayer[] LinkedLayers
28 | {
29 | get;
30 | set;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/BlendMode.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Text;
21 |
22 | namespace Ntreev.Library.Psd
23 | {
24 | public enum BlendMode
25 | {
26 | PassThrough,
27 |
28 | Normal,
29 |
30 | Dissolve,
31 |
32 | Darken,
33 |
34 | Multiply,
35 |
36 | ColorBurn,
37 |
38 | LinearBurn,
39 |
40 | DarkerColor,
41 |
42 | Lighten,
43 |
44 | Screen,
45 |
46 | ColorDodge,
47 |
48 | LinearDodge,
49 |
50 | LighterColor,
51 |
52 | Overlay,
53 |
54 | SoftLight,
55 |
56 | HardLight,
57 |
58 | VividLight,
59 |
60 | LinearLight,
61 |
62 | PinLight,
63 |
64 | HardMix,
65 |
66 | Difference,
67 |
68 | Exclusion,
69 |
70 | Subtract,
71 |
72 | Divide,
73 |
74 | Hue,
75 |
76 | Saturation,
77 |
78 | Color,
79 |
80 | Luminosity,
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/ChannelType.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public enum ChannelType
26 | {
27 | Alpha = -1,
28 |
29 | Red = 0,
30 |
31 | Green = 1,
32 |
33 | Blue = 2,
34 |
35 | Mask = -2,
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/ColorMode.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public enum ColorMode
26 | {
27 | Bitmap = 0,
28 |
29 | CMYK = 4,
30 |
31 | DUOTONE = 8,
32 |
33 | GrayScale = 1,
34 |
35 | Indexed = 2,
36 |
37 | LAB = 9,
38 |
39 | MultiChannel = 7,
40 |
41 | RGB = 3
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/ColorSpace.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public enum ColorSpace
26 | {
27 | ANPA = 0xbb8,
28 |
29 | CMYK = 2,
30 |
31 | DIC = 11,
32 |
33 | FOCOLTONE = 4,
34 |
35 | GRAYSCALE = 8,
36 |
37 | HKS = 10,
38 |
39 | HSB = 1,
40 |
41 | LAB = 7,
42 |
43 | PANTONE = 3,
44 |
45 | RGB = 0,
46 |
47 | TOYO = 6,
48 |
49 | TRUMATCH = 5
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/CompressionType.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public enum CompressionType
26 | {
27 | Raw = 0,
28 |
29 | RLE = 1,
30 |
31 | Zip = 2,
32 |
33 | ZipPrediction = 3,
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/DescriptorStructure.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Structures;
19 | using System;
20 | using System.Collections;
21 | using System.Collections.Generic;
22 | using System.IO;
23 |
24 | namespace Ntreev.Library.Psd
25 | {
26 | class DescriptorStructure : Properties
27 | {
28 | private readonly int version;
29 |
30 | public DescriptorStructure(PsdReader reader)
31 | : this(reader, true)
32 | {
33 |
34 | }
35 |
36 | public DescriptorStructure(PsdReader reader, bool hasVersion)
37 | {
38 | if (hasVersion == true)
39 | {
40 | this.version = reader.ReadInt32();
41 | }
42 |
43 | this.Add("Name", reader.ReadString());
44 | this.Add("ClassID", reader.ReadKey());
45 |
46 | int count = reader.ReadInt32();
47 | for (int i = 0; i < count; i++)
48 | {
49 | string key = reader.ReadKey();
50 | string osType = reader.ReadType();
51 | if (key == "EngineData")
52 | {
53 | this.Add(key.Trim(), new StructureEngineData(reader));
54 | }
55 | else
56 | {
57 | object value = StructureReader.Read(osType, reader);
58 | this.Add(key.Trim(), value);
59 | }
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/EmbeddedLayer.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers.LayerAndMaskInformation;
19 | using System;
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Linq;
23 | using System.Text;
24 |
25 | namespace Ntreev.Library.Psd
26 | {
27 | class EmbeddedLayer : ILinkedLayer
28 | {
29 | private readonly Guid id;
30 | private readonly PsdResolver resolver;
31 | private readonly Uri absoluteUri;
32 | private PsdDocument document;
33 | private readonly int width;
34 | private readonly int height;
35 |
36 | public EmbeddedLayer(Guid id, PsdResolver resolver, Uri absoluteUri)
37 | {
38 | this.id = id;
39 | this.resolver = resolver;
40 | this.absoluteUri = absoluteUri;
41 |
42 | if (File.Exists(this.absoluteUri.LocalPath) == true)
43 | {
44 | var header = FileHeaderSection.FromFile(this.absoluteUri.LocalPath);
45 | this.width = header.Width;
46 | this.height = header.Height;
47 | }
48 | }
49 |
50 | public PsdDocument Document
51 | {
52 | get
53 | {
54 | if (this.document == null)
55 | {
56 | this.document = this.resolver.GetDocument(this.absoluteUri);
57 | }
58 | return this.document;
59 | }
60 | }
61 |
62 | public Uri AbsoluteUri
63 | {
64 | get { return this.absoluteUri; }
65 | }
66 |
67 | public bool HasDocument
68 | {
69 | get { return File.Exists(this.absoluteUri.LocalPath); }
70 | }
71 |
72 | public Guid ID
73 | {
74 | get { return this.id; }
75 | }
76 |
77 | public string Name
78 | {
79 | get { return this.absoluteUri.LocalPath; }
80 | }
81 |
82 | public int Width
83 | {
84 | get { return this.width; }
85 | }
86 |
87 | public int Height
88 | {
89 | get { return this.height; }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Extensions.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public static class Extensions
26 | {
27 | public static byte[] MergeChannels(this IImageSource imageSource)
28 | {
29 | IChannel[] channels = imageSource.Channels;
30 |
31 | int length = channels.Length;
32 | int num2 = channels[0].Data.Length;
33 |
34 | byte[] buffer = new byte[(imageSource.Width * imageSource.Height) * length];
35 | int num3 = 0;
36 | for (int i = 0; i < num2; i++)
37 | {
38 | for (int j = channels.Length - 1; j >= 0; j--)
39 | {
40 | buffer[num3++] = channels[j].Data[i];
41 | }
42 | }
43 | return buffer;
44 | }
45 |
46 | public static IEnumerable Descendants(this IPsdLayer layer)
47 | {
48 | return Descendants(layer, item => true);
49 | }
50 |
51 | public static IEnumerable Descendants(this IPsdLayer layer, Func filter)
52 | {
53 | foreach (var item in layer.Childs)
54 | {
55 | if (filter(item) == false)
56 | continue;
57 |
58 | yield return item;
59 |
60 | foreach (var child in item.Descendants(filter))
61 | {
62 | yield return child;
63 | }
64 | }
65 | }
66 |
67 | internal static IEnumerable Descendants(this PsdLayer layer)
68 | {
69 | yield return layer;
70 |
71 | foreach (var item in layer.Childs)
72 | {
73 | foreach (var child in item.Descendants())
74 | {
75 | yield return child;
76 | }
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/FileHeaderSection.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers;
19 | using System;
20 | using System.IO;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public struct FileHeaderSection
26 | {
27 | public int Depth
28 | {
29 | get;
30 | set;
31 | }
32 |
33 | public int NumberOfChannels
34 | {
35 | get;
36 | set;
37 | }
38 |
39 | public ColorMode ColorMode
40 | {
41 | get;
42 | set;
43 | }
44 |
45 | public int Height
46 | {
47 | get;
48 | set;
49 | }
50 |
51 | public int Width
52 | {
53 | get;
54 | set;
55 | }
56 |
57 | public static FileHeaderSection FromFile(string filename)
58 | {
59 | using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
60 | using (PsdReader reader = new PsdReader(stream, new PathResolver(), new Uri(Path.GetDirectoryName(filename))))
61 | {
62 | reader.ReadDocumentHeader();
63 | return FileHeaderSectionReader.Read(reader);
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/IChannel.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public interface IChannel
26 | {
27 | byte[] Data
28 | {
29 | get;
30 | }
31 |
32 | ChannelType Type
33 | {
34 | get;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/IImageSource.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public interface IImageSource
26 | {
27 | int Width { get; }
28 |
29 | int Height { get; }
30 |
31 | int Depth { get; }
32 |
33 | IChannel[] Channels { get; }
34 |
35 | float Opacity { get; }
36 |
37 | bool HasImage { get; }
38 |
39 | bool HasMask { get; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/ILinkedLayer.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public interface ILinkedLayer
26 | {
27 | PsdDocument Document
28 | {
29 | get;
30 | }
31 |
32 | Uri AbsoluteUri
33 | {
34 | get;
35 | }
36 |
37 | bool HasDocument
38 | {
39 | get;
40 | }
41 |
42 | Guid ID
43 | {
44 | get;
45 | }
46 |
47 | string Name
48 | {
49 | get;
50 | }
51 |
52 | int Width
53 | {
54 | get;
55 | }
56 |
57 | int Height
58 | {
59 | get;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/IProperties.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Text;
21 |
22 | namespace Ntreev.Library.Psd
23 | {
24 | public interface IProperties : IEnumerable>
25 | {
26 | bool Contains(string property);
27 |
28 | object this[string property]
29 | {
30 | get;
31 | }
32 |
33 | int Count { get; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/IPsdLayer.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | public interface IPsdLayer : IImageSource
26 | {
27 | BlendMode BlendMode { get; }
28 |
29 | IPsdLayer[] Childs { get; }
30 |
31 | bool IsClipping { get; }
32 |
33 | ILinkedLayer LinkedLayer { get; }
34 |
35 | string Name { get; }
36 |
37 | IPsdLayer Parent { get; }
38 |
39 | IProperties Resources { get; }
40 |
41 | PsdDocument Document { get; }
42 |
43 | int Left { get; }
44 |
45 | int Top { get; }
46 |
47 | int Right { get; }
48 |
49 | int Bottom { get; }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/InternalDocument.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | class InternalDocument : PsdDocument
26 | {
27 | public InternalDocument()
28 | {
29 |
30 | }
31 |
32 | protected override void OnDisposed(EventArgs e)
33 | {
34 | throw new Exception();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/InvalidFormatException.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | class InvalidFormatException : Exception
26 | {
27 | public InvalidFormatException()
28 | : base("Invalid PSD file")
29 | {
30 |
31 | }
32 |
33 | public InvalidFormatException(string message)
34 | : base(message)
35 | {
36 |
37 | }
38 |
39 | public InvalidFormatException(string format, params object[] args)
40 | : base(string.Format(format, args))
41 | {
42 |
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LayerBlendingRanges.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | class LayerBlendingRanges
26 | {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LayerExtraRecords.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers.LayerAndMaskInformation;
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace Ntreev.Library.Psd
25 | {
26 | class LayerExtraRecords
27 | {
28 | private readonly LayerMaskReader layerMask;
29 | private readonly LayerBlendingRangesReader blendingRanges;
30 | private readonly LayerResourceReader resources;
31 | private readonly string name;
32 | private SectionType sectionType;
33 | private Guid placedID;
34 |
35 | public LayerExtraRecords(LayerMaskReader layerMask, LayerBlendingRangesReader blendingRanges, LayerResourceReader resources, string name)
36 | {
37 | this.layerMask = layerMask;
38 | this.blendingRanges = blendingRanges;
39 | this.resources = resources;
40 | this.name = name;
41 |
42 | this.resources.TryGetValue(ref this.name, "luni.Name");
43 | this.resources.TryGetValue(ref this.sectionType, "lsct.SectionType");
44 |
45 | if (this.resources.Contains("SoLd.Idnt") == true)
46 | this.placedID = this.resources.ToGuid("SoLd.Idnt");
47 | else if (this.resources.Contains("SoLE.Idnt") == true)
48 | this.placedID = this.resources.ToGuid("SoLE.Idnt");
49 | }
50 |
51 | public SectionType SectionType
52 | {
53 | get { return this.sectionType; }
54 | }
55 |
56 | public Guid PlacedID
57 | {
58 | get { return this.placedID; }
59 | }
60 |
61 | public string Name
62 | {
63 | get { return this.name; }
64 | }
65 |
66 | public LayerMask Mask
67 | {
68 | get { return this.layerMask.Value; }
69 | }
70 |
71 | public object BlendingRanges
72 | {
73 | get { return this.blendingRanges.Value; }
74 | }
75 |
76 | public IProperties Resources
77 | {
78 | get { return this.resources.Value; }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LayerFlags.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | [Flags]
26 | public enum LayerFlags
27 | {
28 | Transparency = 1,
29 |
30 | Visible = 2,
31 |
32 | Obsolete = 4,
33 |
34 | Unknown0 = 8, // 1 for Photoshop 5.0 and later, tells if bit 4 has useful information;
35 |
36 | Unknown1 = 16, // pixel data irrelevant to appearance of document
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LayerMask.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | class LayerMask
26 | {
27 | public int Left { get; set; }
28 |
29 | public int Top { get; set; }
30 |
31 | public int Right { get; set; }
32 |
33 | public int Bottom { get; set; }
34 |
35 | public byte Color { get; set; }
36 |
37 | public byte Flag { get; set; }
38 |
39 | public int Width
40 | {
41 | get { return this.Right - this.Left; }
42 | }
43 |
44 | public int Height
45 | {
46 | get { return this.Bottom - this.Top; }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LayerandMaskInformationSection.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers;
19 | using Ntreev.Library.Psd.Readers.LayerAndMaskInformation;
20 | using System;
21 | using System.Collections.Generic;
22 | using System.Linq;
23 | using System.Text;
24 |
25 | namespace Ntreev.Library.Psd
26 | {
27 | class LayerAndMaskInformationSection
28 | {
29 | private readonly LayerInfoReader layerInfo;
30 | private readonly GlobalLayerMaskInfoReader globalLayerMask;
31 | private readonly IProperties documentResources;
32 |
33 | private ILinkedLayer[] linkedLayers;
34 |
35 | public LayerAndMaskInformationSection(LayerInfoReader layerInfo, GlobalLayerMaskInfoReader globalLayerMask, IProperties documentResources)
36 | {
37 | this.layerInfo = layerInfo;
38 | this.globalLayerMask = globalLayerMask;
39 | this.documentResources = documentResources;
40 | }
41 |
42 | public PsdLayer[] Layers
43 | {
44 | get { return this.layerInfo.Value; }
45 | }
46 |
47 | public ILinkedLayer[] LinkedLayers
48 | {
49 | get
50 | {
51 | if (this.linkedLayers == null)
52 | {
53 | List list = new List();
54 | string[] ids = { "lnk2", "lnk3", "lnkD", "lnkE", };
55 |
56 | foreach (var item in ids)
57 | {
58 | if (this.documentResources.Contains(item))
59 | {
60 | var items = this.documentResources.ToValue(item, "Items");
61 | list.AddRange(items);
62 | }
63 | }
64 | this.linkedLayers = list.ToArray();
65 | }
66 | return this.linkedLayers;
67 | }
68 | }
69 |
70 | public IProperties Resources
71 | {
72 | get { return this.documentResources; }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LazyProperties.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | abstract class LazyProperties : LazyValueReader, IProperties
26 | {
27 | protected LazyProperties(PsdReader reader, object userData)
28 | : base(reader, userData)
29 | {
30 |
31 | }
32 |
33 | protected LazyProperties(PsdReader reader, long length, object userData)
34 | : base(reader, length, userData)
35 | {
36 |
37 | }
38 |
39 | public bool Contains(string property)
40 | {
41 | return this.Value.Contains(property);
42 | }
43 |
44 | public object this[string property]
45 | {
46 | get { return this.Value[property]; }
47 | }
48 |
49 | public int Count
50 | {
51 | get { return this.Value.Count; }
52 | }
53 |
54 | #region IProperties
55 |
56 | IEnumerator> IEnumerable>.GetEnumerator()
57 | {
58 | return (this.Value as IProperties).GetEnumerator();
59 | }
60 |
61 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
62 | {
63 | return (this.Value as IProperties).GetEnumerator();
64 | }
65 |
66 | #endregion
67 | }
68 | }
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LazyValueReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd
24 | {
25 | abstract class LazyValueReader : ValueReader
26 | {
27 | protected LazyValueReader(PsdReader reader, object userData)
28 | : base(reader, true, userData)
29 | {
30 |
31 | }
32 |
33 | protected LazyValueReader(PsdReader reader, long length, object userData)
34 | : base(reader, length, userData)
35 | {
36 |
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/LinkedLayer.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers.LayerAndMaskInformation;
19 | using System;
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Linq;
23 | using System.Text;
24 |
25 | namespace Ntreev.Library.Psd
26 | {
27 | class LinkedLayer : ILinkedLayer
28 | {
29 | private readonly string name;
30 | private readonly Guid id;
31 | private readonly LinkedDocumentReader documentReader;
32 | private readonly LinkedDocumnetFileHeaderReader fileHeaderReader;
33 |
34 | public LinkedLayer(string name, Guid id, LinkedDocumentReader documentReader, LinkedDocumnetFileHeaderReader fileHeaderReader)
35 | {
36 | this.name = name;
37 | this.id = id;
38 | this.documentReader = documentReader;
39 | this.fileHeaderReader = fileHeaderReader;
40 | }
41 |
42 | public PsdDocument Document
43 | {
44 | get
45 | {
46 | if (this.documentReader == null)
47 | return null;
48 | return this.documentReader.Value;
49 | }
50 | }
51 |
52 | public Uri AbsoluteUri
53 | {
54 | get { return null; }
55 | }
56 |
57 | public bool HasDocument
58 | {
59 | get { return this.documentReader != null; }
60 | }
61 |
62 | public Guid ID
63 | {
64 | get { return this.id; }
65 | }
66 |
67 | public string Name
68 | {
69 | get { return this.name; }
70 | }
71 |
72 | public int Width
73 | {
74 | get { return this.fileHeaderReader.Value.Width; }
75 | }
76 |
77 | public int Height
78 | {
79 | get { return this.fileHeaderReader.Value.Height; }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Ntreev.Library.Psd.csproj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NtreevSoft/psd-parser/5866c373d98707d3cbe9fe0616011698b98c85a0/Ntreev.Library.Psd/Ntreev.Library.Psd.csproj
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/PathResolver.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace Ntreev.Library.Psd
25 | {
26 | public class PathResolver : PsdResolver
27 | {
28 | private readonly Dictionary uriToDocuments = new Dictionary();
29 |
30 | public override PsdDocument GetDocument(Uri absoluteUri)
31 | {
32 | string filename = absoluteUri.LocalPath;
33 | if (File.Exists(filename) == false)
34 | throw new FileNotFoundException(string.Format("{0} 파일을 찾을 수 없습니다.", filename), filename);
35 |
36 | if (uriToDocuments.ContainsKey(absoluteUri) == false)
37 | {
38 | PsdDocument document = PsdDocument.Create(filename);
39 | uriToDocuments.Add(absoluteUri, document);
40 | }
41 |
42 | return uriToDocuments[absoluteUri];
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/PsdResolver.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace Ntreev.Library.Psd
25 | {
26 | public abstract class PsdResolver
27 | {
28 | public abstract PsdDocument GetDocument(Uri absoluteUri);
29 |
30 | public virtual Uri ResolveUri(Uri baseUri, string relativeUri)
31 | {
32 | if ((baseUri == null) || (!baseUri.IsAbsoluteUri && (baseUri.OriginalString.Length == 0)))
33 | {
34 | Uri uri = new Uri(relativeUri, UriKind.RelativeOrAbsolute);
35 | if (!uri.IsAbsoluteUri && (uri.OriginalString.Length > 0))
36 | {
37 | uri = new Uri(Path.GetFullPath(relativeUri));
38 | }
39 | return uri;
40 | }
41 | if ((relativeUri == null) || (relativeUri.Length == 0))
42 | {
43 | return baseUri;
44 | }
45 | if (!baseUri.IsAbsoluteUri)
46 | {
47 | throw new NotSupportedException("PSD_RelativeUriNotSupported");
48 | }
49 | return new Uri(baseUri, relativeUri);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/ColorModeDataSectionReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd.Readers
24 | {
25 | class ColorModeDataSectionReader : LazyValueReader
26 | {
27 | public ColorModeDataSectionReader(PsdReader reader)
28 | : base(reader, null)
29 | {
30 |
31 | }
32 |
33 | protected override long OnLengthGet(PsdReader reader)
34 | {
35 | return reader.ReadInt32();
36 | }
37 |
38 | protected override void ReadValue(PsdReader reader, object userData, out byte[] value)
39 | {
40 | if (this.Length > 0)
41 | {
42 | value = reader.ReadBytes((int)this.Length);
43 | }
44 | else
45 | {
46 | value = new byte[] { };
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/EmptyResourceReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd.Readers
24 | {
25 | class EmptyResourceReader : ResourceReaderBase
26 | {
27 | public EmptyResourceReader(PsdReader reader, long length)
28 | : base(reader, length)
29 | {
30 |
31 | }
32 |
33 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
34 | {
35 | value = new Properties();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/FileHeaderSectionReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd.Readers
24 | {
25 | class FileHeaderSectionReader : ValueReader
26 | {
27 | public FileHeaderSectionReader(PsdReader reader)
28 | : base(reader, false, null)
29 | {
30 |
31 | }
32 |
33 | public static FileHeaderSection Read(PsdReader reader)
34 | {
35 | FileHeaderSectionReader instance = new FileHeaderSectionReader(reader);
36 | return instance.Value;
37 | }
38 |
39 | protected override void ReadValue(PsdReader reader, object userData, out FileHeaderSection value)
40 | {
41 | value = new FileHeaderSection();
42 |
43 | value.NumberOfChannels = reader.ReadInt16();
44 | value.Height = reader.ReadInt32();
45 | value.Width = reader.ReadInt32();
46 | value.Depth = reader.ReadInt16();
47 | value.ColorMode = reader.ReadColorMode();
48 |
49 | if (value.Depth != 8)
50 | {
51 | throw new NotSupportedException("only support 8 Bit Channel");
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/ImageResources/Reader_GridAndGuides.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd.Readers.ImageResources
24 | {
25 | [ResourceID("1032", DisplayName = "GridAndGuides")]
26 | class Reader_GridAndGuides : ResourceReaderBase
27 | {
28 | public Reader_GridAndGuides(PsdReader reader, long length)
29 | : base(reader, length)
30 | {
31 |
32 | }
33 |
34 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
35 | {
36 | Properties props = new Properties();
37 |
38 | int version = reader.ReadInt32();
39 |
40 | if (version != 1)
41 | throw new InvalidFormatException();
42 |
43 | props["HorizontalGrid"] = reader.ReadInt32();
44 | props["VerticalGrid"] = reader.ReadInt32();
45 |
46 | int guideCount = reader.ReadInt32();
47 |
48 | List hg = new List();
49 | List vg = new List();
50 |
51 | for (int i = 0; i < guideCount; i++)
52 | {
53 | int n = reader.ReadInt32();
54 | byte t = reader.ReadByte();
55 |
56 | if (t == 0)
57 | vg.Add(n);
58 | else
59 | hg.Add(n);
60 | }
61 |
62 | props["HorizontalGuides"] = hg.ToArray();
63 | props["VerticalGuides"] = vg.ToArray();
64 |
65 | value = props;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/ImageResources/Reader_ResolutionInfo.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 |
22 | namespace Ntreev.Library.Psd.Readers.ImageResources
23 | {
24 | [ResourceID("1005", DisplayName = "Resolution")]
25 | class Reader_ResolutionInfo : ResourceReaderBase
26 | {
27 | public Reader_ResolutionInfo(PsdReader reader, long length)
28 | : base(reader, length)
29 | {
30 |
31 | }
32 |
33 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
34 | {
35 | Properties props = new Properties(6);
36 |
37 | props["HorizontalRes"] = reader.ReadInt16();
38 | props["HorizontalResUnit"] = reader.ReadInt32();
39 | props["WidthUnit"] = reader.ReadInt16();
40 | props["VerticalRes"] = reader.ReadInt16();
41 | props["VerticalResUnit"] = reader.ReadInt32();
42 | props["HeightUnit"] = reader.ReadInt16();
43 |
44 | value = props;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/ImageResources/Reader_VersionInfo.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 |
23 | namespace Ntreev.Library.Psd.Readers.ImageResources
24 | {
25 | [ResourceID("1057", DisplayName = "Version")]
26 | class Reader_VersionInfo : ResourceReaderBase
27 | {
28 | public Reader_VersionInfo(PsdReader reader, long length)
29 | : base(reader, length)
30 | {
31 |
32 | }
33 |
34 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
35 | {
36 | Properties props = new Properties(5);
37 |
38 | props["Version"] = reader.ReadInt32();
39 | props["HasCompatibilityImage"] = reader.ReadBoolean();
40 | props["WriterName"] = reader.ReadString();
41 | props["ReaderName"] = reader.ReadString();
42 | props["FileVersion"] = reader.ReadInt32();
43 |
44 | value = props;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/ImageResourcesSectionReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using Ntreev.Library.Psd.Readers;
19 | using Ntreev.Library.Psd.Readers.ImageResources;
20 | using System;
21 | using System.Collections.Generic;
22 | using System.ComponentModel;
23 | using System.Linq;
24 | using System.Text;
25 |
26 | namespace Ntreev.Library.Psd.Readers
27 | {
28 | class ImageResourcesSectionReader : LazyProperties
29 | {
30 | public ImageResourcesSectionReader(PsdReader reader)
31 | : base(reader, null)
32 | {
33 |
34 | }
35 |
36 | protected override long OnLengthGet(PsdReader reader)
37 | {
38 | return reader.ReadInt32();
39 | }
40 |
41 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
42 | {
43 | Properties props = new Properties();
44 |
45 | while(reader.Position < this.EndPosition)
46 | {
47 | reader.ValidateSignature();
48 |
49 | string resourceID = reader.ReadInt16().ToString();
50 | string name = reader.ReadPascalString(2);
51 | long length = reader.ReadInt32();
52 | length += (length % 2);
53 |
54 | ResourceReaderBase resourceReader = ReaderCollector.CreateReader(resourceID, reader, length);
55 | string resourceName = ReaderCollector.GetDisplayName(resourceID);
56 |
57 | props[resourceName] = resourceReader;
58 | }
59 |
60 | value = props;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/LayerAndMaskInformation/ChannelsReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace Ntreev.Library.Psd.Readers.LayerAndMaskInformation
25 | {
26 | class ChannelsReader : LazyValueReader
27 | {
28 | public ChannelsReader(PsdReader reader, long length, PsdLayer layer)
29 | : base(reader, length, layer)
30 | {
31 |
32 | }
33 |
34 | protected override void ReadValue(PsdReader reader, object userData, out Channel[] value)
35 | {
36 | PsdLayer layer = userData as PsdLayer;
37 | LayerRecords records = layer.Records;
38 |
39 | using (MemoryStream stream = new MemoryStream(reader.ReadBytes((int)this.Length)))
40 | using (PsdReader r = new PsdReader(stream, reader.Resolver, reader.Uri))
41 | {
42 | r.Version = reader.Version;
43 | this.ReadValue(r, layer.Depth, records.Channels);
44 | }
45 |
46 | value = records.Channels;
47 | }
48 |
49 | private void ReadValue(PsdReader reader, int depth, Channel[] channels)
50 | {
51 | foreach (var item in channels)
52 | {
53 | CompressionType compressionType = reader.ReadCompressionType();
54 | item.ReadHeader(reader, compressionType);
55 | item.Read(reader, depth, compressionType);
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/LayerAndMaskInformation/DocumentResourceReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 |
23 | namespace Ntreev.Library.Psd.Readers.LayerAndMaskInformation
24 | {
25 | class DocumentResourceReader : LazyProperties
26 | {
27 | private static string[] doubleTypeKeys = { "LMsk", "Lr16", "Lr32", "Layr", "Mt16", "Mt32", "Mtrn", "Alph", "FMsk", "lnk2", "FEid", "FXid", "PxSD", "lnkE", "extd", };
28 |
29 | public DocumentResourceReader(PsdReader reader, long length)
30 | : base(reader, length, null)
31 | {
32 |
33 | }
34 |
35 | protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
36 | {
37 | Properties props = new Properties();
38 |
39 | while (reader.Position < this.EndPosition)
40 | {
41 | reader.ValidateSignature(true);
42 | string resourceID = reader.ReadType();
43 | long length = this.ReadLength(reader, resourceID);
44 |
45 | ResourceReaderBase resourceReader = ReaderCollector.CreateReader(resourceID, reader, length);
46 | string resourceName = ReaderCollector.GetDisplayName(resourceID);
47 |
48 | props[resourceName] = resourceReader;
49 | }
50 |
51 | value = props;
52 | }
53 |
54 | private long ReadLength(PsdReader reader, string resourceID)
55 | {
56 | long length = 0;
57 | if (doubleTypeKeys.Contains(resourceID) && reader.Version == 2)
58 | {
59 | length = reader.ReadInt64();
60 | }
61 | else if(reader.Version == 2)
62 | {
63 | length = reader.ReadInt64();
64 | }
65 | else
66 | {
67 | length = reader.ReadInt32();
68 | }
69 |
70 | return (length + 3) & (~3);
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/Ntreev.Library.Psd/Readers/LayerAndMaskInformation/GlobalLayerMaskInfoReader.cs:
--------------------------------------------------------------------------------
1 | //Released under the MIT License.
2 | //
3 | //Copyright (c) 2015 Ntreev Soft co., Ltd.
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 | //documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7 | //rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | //persons to whom the Software is furnished to do so, subject to the following conditions:
9 | //
10 | //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11 | //Software.
12 | //
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | //WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | //OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace Ntreev.Library.Psd.Readers.LayerAndMaskInformation
25 | {
26 | class GlobalLayerMaskInfoReader : ValueReader