Exemplo n.º 1
0
        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);

                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;
        }
Exemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////////

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

            m_imageResources.Clear();

            uint imgResLength = reader.ReadUInt32();

            if (imgResLength <= 0)
            {
                return;
            }

            long startPosition = reader.BaseStream.Position;

            while ((reader.BaseStream.Position - startPosition) < imgResLength)
            {
                ImageResource imgRes = new ImageResource(reader);

                ResourceIDs resID = (ResourceIDs)imgRes.ID;
                switch (resID)
                {
                case ResourceIDs.ResolutionInfo:
                    imgRes = new ResolutionInfo(imgRes);
                    break;

                case ResourceIDs.Thumbnail1:
                case ResourceIDs.Thumbnail2:
                    imgRes = new Thumbnail(imgRes);
                    break;

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

                m_imageResources.Add(imgRes);
            }

            //-----------------------------------------------------------------------
            // make sure we are not on a wrong offset, so set the stream position
            // manually
            reader.BaseStream.Position = startPosition + imgResLength;
        }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////////

        private void LoadImageResources(BinaryReverseReader reader)
        {
            Debug.WriteLine("LoadImageResources started at " + reader.BaseStream.Position);

            m_imageResources.Clear();

            uint imgResLength = reader.ReadUInt32();
            if (imgResLength <= 0)
                return;

            long startPosition = reader.BaseStream.Position;

            while ((reader.BaseStream.Position - startPosition) < imgResLength)
            {
                var imgRes = new ImageResource(reader);

                var resID = (ResourceIDs)imgRes.ID;
                switch (resID)
                {
                    case ResourceIDs.ResolutionInfo:
                        imgRes = new ResolutionInfo(imgRes);
                        break;
                    case ResourceIDs.Thumbnail1:
                    case ResourceIDs.Thumbnail2:
                        imgRes = new Thumbnail(imgRes);
                        break;
                    case ResourceIDs.AlphaChannelNames:
                        imgRes = new AlphaChannels(imgRes);
                        break;
                }

                m_imageResources.Add(imgRes);
            }

            //-----------------------------------------------------------------------
            // make shure we are not on a wrong offset, so set the stream position 
            // manually
            reader.BaseStream.Position = startPosition + imgResLength;
        }
Exemplo n.º 4
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);
                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;
                }

                ImageResources.Add(imgRes);
            }

            reader.BaseStream.Position = position + num;
        }