public List <ImageResourceBlock> Read(Stream stream, ImageResourcesSection imageResourcesSection)
        {
            var list = new List <ImageResourceBlock>();

            var reader = new BigEndianBinaryReader(stream);

            stream.Position = imageResourcesSection.Offset;

            while (reader.BaseStream.Position < imageResourcesSection.Offset + imageResourcesSection.Length)
            {
                var imageResource = new ImageResourceBlock();

                imageResource.Signature = new string(reader.ReadChars(4));
                imageResource.Id        = (ImageResourceId)reader.ReadInt16();
                imageResource.Name      = reader.ReadPascalString();

                imageResource.Length = reader.ReadInt32();

                if ((imageResource.Length % 2) != 0)
                {
                    imageResource.Length++;
                }

                imageResource.Offset = stream.Position;
                stream.Position     += imageResource.Length;

                list.Add(imageResource);
            }

            return(list);
        }
        public ImageResourcesSection Read(Stream stream)
        {
            var imageResourcesSection = new ImageResourcesSection();
            var reader = new BigEndianBinaryReader(stream);

            imageResourcesSection.Length = reader.ReadInt32();
            imageResourcesSection.Offset = reader.BaseStream.Position;

            stream.Position += imageResourcesSection.Length;

            return(imageResourcesSection);
        }
示例#3
0
        private PhotoshopFile(
            [NotNull] Stream stream,
            [NotNull] PhotoshopFileSectionReader <HeaderSection> headerSectionReader,
            [NotNull] PhotoshopFileSectionReader <ColorModeDataSection> colorModeDataSectionReader,
            [NotNull] PhotoshopFileSectionReader <ImageResourcesSection> imageResourcesSectionReader,
            [NotNull] PhotoshopFileSectionReader <LayerMaskInformationSection> layerMaskInformationSectionReader,
            [NotNull] PhotoshopFileSectionReader <ImageDataSection> imageDataSectionReader)
        {
            Assert.NotNull(stream, nameof(stream));
            Assert.NotNull(headerSectionReader, nameof(headerSectionReader));
            Assert.NotNull(colorModeDataSectionReader, nameof(colorModeDataSectionReader));
            Assert.NotNull(imageResourcesSectionReader, nameof(imageResourcesSectionReader));
            Assert.NotNull(layerMaskInformationSectionReader, nameof(layerMaskInformationSectionReader));
            Assert.NotNull(imageDataSectionReader, nameof(imageDataSectionReader));

            _stream = stream;
            _reader = new PhotoshopFileReader(stream);

            _headerSection               = headerSectionReader.ReadSection(_reader, this);
            _colorModeDataSection        = colorModeDataSectionReader.ReadSection(_reader, this);
            _imageResourcesSection       = imageResourcesSectionReader.ReadSection(_reader, this);
            _layerMaskInformationSection = layerMaskInformationSectionReader.ReadSection(_reader, this);
            _imageDataSection            = imageDataSectionReader.ReadSection(_reader, this);
        }