Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////

        internal void LoadPixelData(PsdBinaryReader reader)
        {
            Util.DebugMessage(reader.BaseStream, "Load, Begin, Channel image");

            if (Length == 0)
            {
                ImageCompression = ImageCompression.Raw;
                ImageDataRaw     = new byte[0];
                return;
            }

            var endPosition = reader.BaseStream.Position + this.Length;

            ImageCompression = (ImageCompression)reader.ReadInt16();
            var longDataLength = this.Length - 2;

            Util.CheckByteArrayLength(longDataLength);
            var dataLength = (int)longDataLength;

            switch (ImageCompression)
            {
            case ImageCompression.Raw:
                ImageDataRaw = reader.ReadBytes(dataLength);
                break;

            case ImageCompression.Rle:
                // RLE row lengths
                RleRowLengths = new RleRowLengths(reader, Rect.Height,
                                                  Layer.PsdFile.IsLargeDocument);
                var rleDataLength = (int)(endPosition - reader.BaseStream.Position);
                Debug.Assert(rleDataLength == RleRowLengths.Total,
                             "RLE row lengths do not sum to length of channel image data.");

                // The PSD specification states that rows are padded to even sizes.
                // However, Photoshop doesn't actually do this.  RLE rows can have
                // odd lengths in the header, and there is no padding between rows.
                ImageDataRaw = reader.ReadBytes(rleDataLength);
                break;

            case ImageCompression.Zip:
            case ImageCompression.ZipPrediction:
                ImageDataRaw = reader.ReadBytes(dataLength);
                break;
            }

            Util.DebugMessage(reader.BaseStream, $"Load, End, Channel image, {ID}");
            Debug.Assert(reader.BaseStream.Position == endPosition,
                         "Pixel data was not fully read in.");
        }
Ejemplo n.º 2
0
 public RawImageResource(PsdBinaryReader reader, string signature,
                         ResourceID resourceId, string name, int numBytes)
     : base(name)
 {
     this.Signature = signature;
     this.id        = resourceId;
     Data           = reader.ReadBytes(numBytes);
 }
Ejemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////////

        public BlendingRanges(PsdBinaryReader reader, Layer layer)
        {
            Util.DebugMessage(reader.BaseStream, "Load, Begin, BlendingRanges");

            Layer = layer;
            var dataLength = reader.ReadInt32();

            if (dataLength <= 0)
            {
                return;
            }

            Data = reader.ReadBytes(dataLength);

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