Пример #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
        /// <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;
        }