Пример #1
0
        ///////////////////////////////////////////////////////////////////////////

        private void LoadImageResources(PsdBinaryReader reader)
        {
            Debug.WriteLine("LoadImageResources started at " + reader.BaseStream.Position.ToString(CultureInfo.InvariantCulture));

            ImageResources.Clear();

            var imageResourcesLength = reader.ReadUInt32();

            if (imageResourcesLength <= 0)
            {
                return;
            }

            var startPosition = reader.BaseStream.Position;
            var endPosition   = startPosition + imageResourcesLength;

            while (reader.BaseStream.Position < endPosition)
            {
                var imageResource = ImageResourceFactory.CreateImageResource(reader);
                ImageResources.Add(imageResource);
            }

            //-----------------------------------------------------------------------
            // make sure we are not on a wrong offset, so set the stream position
            // manually
            reader.BaseStream.Position = startPosition + imageResourcesLength;
        }
Пример #2
0
        ///////////////////////////////////////////////////////////////////////////

        private void LoadImageResources(PsdBinaryReader reader)
        {
            Util.DebugMessage(reader.BaseStream, "Load, Begin, ImageResources");

            var imageResourcesLength = reader.ReadUInt32();

            if (imageResourcesLength <= 0)
            {
                return;
            }

            var startPosition = reader.BaseStream.Position;
            var endPosition   = startPosition + imageResourcesLength;

            while (reader.BaseStream.Position < endPosition)
            {
                var imageResource = ImageResourceFactory.CreateImageResource(reader);
                ImageResources.Add(imageResource);
            }

            Util.DebugMessage(reader.BaseStream, "Load, End, ImageResources");

            //-----------------------------------------------------------------------
            // make sure we are not on a wrong offset, so set the stream position
            // manually
            reader.BaseStream.Position = startPosition + imageResourcesLength;
        }
Пример #3
0
        public PsdFile(PsdFileVersion version = PsdFileVersion.Psd)
        {
            Version = version;

            BaseLayer      = new Layer(this);
            ImageResources = new ImageResources();
            Layers         = new List <Layer>();
            AdditionalInfo = new List <LayerInfo>();
        }
Пример #4
0
        ///////////////////////////////////////////////////////////////////////////

        public PsdFile()
        {
            Version        = 1;
            BaseLayer      = new Layer(this);
            BaseLayer.Rect = new Rectangle(0, 0, 0, 0);

            ImageResources = new ImageResources();
            Layers         = new List <Layer>();
            AdditionalInfo = new List <LayerInfo>();
        }
Пример #5
0
        /// <summary>
        /// Reads the image resources from the reader.
        /// </summary>
        /// <param name="reader">The reader to use to read the image resources.</param>
        private void LoadImageResources(BinaryReverseReader reader)
        {
            ImageResources.Clear();
            uint num = reader.ReadUInt32();

            if (num <= 0U)
            {
                return;
            }

            long position = reader.BaseStream.Position;

            while (reader.BaseStream.Position - position < num)
            {
                ImageResource imgRes = new ImageResource(reader);
                //Debug.Log(Time.time + ",read imgRes.ID= " + imgRes.ID);
                switch ((ResourceIDs)imgRes.ID)
                {
                case ResourceIDs.XMLInfo:
                    MetaData = XDocument.Load(XmlReader.Create(new MemoryStream(imgRes.Data)));
                    IEnumerable <XElement> source = MetaData.Descendants(XName.Get("Category", "http://ns.adobe.com/photoshop/1.0/"));
                    if (source.Any())
                    {
                        Category = source.First().Value;
                    }
                    break;

                case ResourceIDs.ResolutionInfo:
                    imgRes = new ResolutionInfo(imgRes);
                    break;

                case ResourceIDs.AlphaChannelNames:
                    imgRes = new AlphaChannels(imgRes);
                    break;

                case ResourceIDs.PsCCOrignPathInfo:
                    imgRes = new AlphaChannels(imgRes);
                    break;

                case ResourceIDs.PsCCPathSelectionState:
                    imgRes = new AlphaChannels(imgRes);
                    break;

                case ResourceIDs.TransparencyIndex:
                    Debug.Log("have transparent ");
                    break;
                }

                ImageResources.Add(imgRes);
            }

            reader.BaseStream.Position = position + num;
        }
Пример #6
0
        /// <summary>
        /// Set the VersionInfo resource on the file.
        /// </summary>
        public void SetVersionInfo()
        {
            var versionInfo = (VersionInfo)ImageResources.Get(ResourceID.VersionInfo);

            if (versionInfo == null)
            {
                versionInfo = new VersionInfo();
                ImageResources.Set(versionInfo);

                // Get the version string.  We don't use the fourth part (revision).
                var assembly      = System.Reflection.Assembly.GetExecutingAssembly();
                var version       = assembly.GetName().Version;
                var versionString = version.Major + "." + version.Minor + "." + version.Build;

                // Strings are not localized since they are not shown to the user.
                versionInfo.Version           = 1;
                versionInfo.HasRealMergedData = true;
                versionInfo.ReaderName        = "Paint.NET PSD Plugin";
                versionInfo.WriterName        = "Paint.NET PSD Plugin " + versionString;
                versionInfo.FileVersion       = 1;
            }
        }