コード例 #1
0
        internal static GifBlock ReadBlock(
            Stream stream,
            IEnumerable <GifExtension> controlExtensions,
            bool metadataOnly)
        {
            int blockId = stream.ReadByte();

            if (blockId < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            if (blockId == 33)
            {
                return((GifBlock)GifExtension.ReadExtension(stream, controlExtensions, metadataOnly));
            }
            if (blockId == 44)
            {
                return((GifBlock)GifFrame.ReadFrame(stream, controlExtensions, metadataOnly));
            }
            if (blockId == 59)
            {
                return((GifBlock)GifTrailer.ReadTrailer());
            }
            throw GifHelpers.UnknownBlockTypeException(blockId);
        }
コード例 #2
0
 private void Read(Stream stream)
 {
     byte[] bytes = GifHelpers.ReadDataBlocks(stream, false);
     if (bytes == null)
     {
         return;
     }
     this.Text = Encoding.ASCII.GetString(bytes);
 }
コード例 #3
0
 private void Read(
     Stream stream,
     IEnumerable <GifExtension> controlExtensions,
     bool metadataOnly)
 {
     this.Descriptor = GifImageDescriptor.ReadImageDescriptor(stream);
     if (this.Descriptor.HasLocalColorTable)
     {
         this.LocalColorTable = GifHelpers.ReadColorTable(stream, this.Descriptor.LocalColorTableSize);
     }
     this.ImageData  = GifImageData.ReadImageData(stream, metadataOnly);
     this.Extensions = (IList <GifExtension>)controlExtensions.ToList <GifExtension>().AsReadOnly();
 }
コード例 #4
0
 private void Read(Stream stream)
 {
     this.Signature = GifHelpers.ReadString(stream, 3);
     if (this.Signature != "GIF")
     {
         throw GifHelpers.InvalidSignatureException(this.Signature);
     }
     this.Version = GifHelpers.ReadString(stream, 3);
     if (this.Version != "87a" && this.Version != "89a")
     {
         throw GifHelpers.UnsupportedVersionException(this.Version);
     }
     this.LogicalScreenDescriptor = GifLogicalScreenDescriptor.ReadLogicalScreenDescriptor(stream);
 }
コード例 #5
0
 private void Read(Stream stream)
 {
     byte[] numArray1 = new byte[12];
     stream.ReadAll(numArray1, 0, numArray1.Length);
     this.BlockSize = (int)numArray1[0];
     if (this.BlockSize != 11)
     {
         throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, this.BlockSize);
     }
     this.ApplicationIdentifier = Encoding.ASCII.GetString(numArray1, 1, 8);
     byte[] numArray2 = new byte[3];
     Array.Copy((Array)numArray1, 9, (Array)numArray2, 0, 3);
     this.AuthenticationCode = numArray2;
     this.Data = GifHelpers.ReadDataBlocks(stream, false);
 }
コード例 #6
0
        private void Read(Stream stream)
        {
            byte[] buffer = new byte[6];
            stream.ReadAll(buffer, 0, buffer.Length);
            this.BlockSize = (int)buffer[0];
            if (this.BlockSize != 4)
            {
                throw GifHelpers.InvalidBlockSizeException("Graphic Control Extension", 4, this.BlockSize);
            }
            byte num = buffer[1];

            this.DisposalMethod    = ((int)num & 28) >> 2;
            this.UserInput         = ((uint)num & 2U) > 0U;
            this.HasTransparency   = ((uint)num & 1U) > 0U;
            this.Delay             = (int)BitConverter.ToUInt16(buffer, 2) * 10;
            this.TransparencyIndex = (int)buffer[4];
        }
コード例 #7
0
 private void Read(
     Stream stream,
     IEnumerable <GifExtension> controlExtensions,
     bool metadataOnly)
 {
     byte[] buffer = new byte[13];
     stream.ReadAll(buffer, 0, buffer.Length);
     this.BlockSize = (int)buffer[0];
     if (this.BlockSize != 12)
     {
         throw GifHelpers.InvalidBlockSizeException("Plain Text Extension", 12, this.BlockSize);
     }
     this.Left                 = (int)BitConverter.ToUInt16(buffer, 1);
     this.Top                  = (int)BitConverter.ToUInt16(buffer, 3);
     this.Width                = (int)BitConverter.ToUInt16(buffer, 5);
     this.Height               = (int)BitConverter.ToUInt16(buffer, 7);
     this.CellWidth            = (int)buffer[9];
     this.CellHeight           = (int)buffer[10];
     this.ForegroundColorIndex = (int)buffer[11];
     this.BackgroundColorIndex = (int)buffer[12];
     this.Text                 = Encoding.ASCII.GetString(GifHelpers.ReadDataBlocks(stream, metadataOnly));
     this.Extensions           = (IList <GifExtension>)controlExtensions.ToList <GifExtension>().AsReadOnly();
 }
コード例 #8
0
 private void Read(Stream stream, bool metadataOnly)
 {
     this.LzwMinimumCodeSize = (byte)stream.ReadByte();
     this.CompressedData     = GifHelpers.ReadDataBlocks(stream, metadataOnly);
 }