当前位置: 首页>>代码示例>>C#>>正文


C# Reader.Unpack方法代码示例

本文整理汇总了C#中Reader.Unpack方法的典型用法代码示例。如果您正苦于以下问题:C# Reader.Unpack方法的具体用法?C# Reader.Unpack怎么用?C# Reader.Unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reader的用法示例。


在下文中一共展示了Reader.Unpack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

 public override ImageData Read(Stream file, ImageMetaData info)
 {
     using (var reader = new Reader (file, info.Width * info.Height))
     {
         reader.Unpack();
         return ImageData.Create (info, PixelFormats.Bgra32, null, reader.Data);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:8,代码来源:ImageWCG.cs

示例2: Read

 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var reader = new Reader (stream, (PrsMetaData)info))
     {
         reader.Unpack();
         return ImageData.Create (info, reader.Format, null, reader.Data, reader.Stride);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:8,代码来源:ImagePRS.cs

示例3: Read

 public override ImageData Read(Stream file, ImageMetaData info)
 {
     var meta = (ElgMetaData)info;
     file.Position = meta.HeaderSize;
     using (var reader = new Reader (file, meta))
     {
         reader.Unpack();
         return ImageData.Create (meta, reader.Format, reader.Palette, reader.Data);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:10,代码来源:ImageELG.cs

示例4: Read

 public override ImageData Read(Stream file, ImageMetaData info)
 {
     file.Position = 0x14;
     using (var reader = new Reader (file, info))
     {
         reader.Unpack();
         var palette = new BitmapPalette (reader.Palette);
         return ImageData.Create (info, PixelFormats.Indexed8, palette, reader.Data, (int)info.Width);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:10,代码来源:ImageRCT.cs

示例5: Read

        public override ImageData Read(Stream stream, ImageMetaData info)
        {
            var meta = info as EpaMetaData;
            if (null == meta)
                throw new ArgumentException ("EpaFormat.Read should be supplied with EpaMetaData", "info");

            stream.Position = 2 == meta.Mode ? 0x18 : 0x10;
            var reader = new Reader (stream, meta);
            reader.Unpack();
            return ImageData.Create (meta, reader.Format, reader.Palette, reader.Data);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:11,代码来源:ImageEPA.cs

示例6: Read

        public override ImageData Read(Stream stream, ImageMetaData info)
        {
            var meta = info as S25MetaData;
            if (null == meta)
                throw new ArgumentException ("S25Format.Read should be supplied with S25MetaData", "info");

            using (var reader = new Reader (stream, meta))
            {
                var pixels = reader.Unpack();
                return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
            }
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:12,代码来源:ImageS25.cs

示例7: Read

        public override ImageData Read(Stream stream, ImageMetaData info)
        {
            var meta = info as Ed8MetaData;
            if (null == meta)
                throw new ArgumentException ("Ed8Format.Read should be supplied with Ed8MetaData", "info");

            stream.Position = 0x1a;
            var reader = new Reader (stream, meta);
            reader.Unpack();
            var palette = new BitmapPalette (reader.Palette);
            return ImageData.Create (info, PixelFormats.Indexed8, palette, reader.Data, (int)info.Width);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:12,代码来源:ImageEDT.cs

示例8: Read

        public override ImageData Read(Stream stream, ImageMetaData info)
        {
            var meta = info as DgcMetaData;
            if (null == meta)
                throw new ArgumentException ("DgcFormat.Read should be supplied with DgcMetaData", "info");

            stream.Position = 12;
            using (var reader = new Reader (stream, meta))
            {
                reader.Unpack();
                return ImageData.Create (info, reader.Format, null, reader.Data);
            }
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:13,代码来源:ImageDGC.cs

示例9: Read

        public override ImageData Read(Stream stream, ImageMetaData info)
        {
            var meta = info as PicMetaData;
            if (null == meta)
                throw new ArgumentException ("PicFormat.Read should be supplied with PicMetaData", "info");

            stream.Position = 0x12;
            using (var reader = new Reader (stream, meta))
            {
                reader.Unpack();
                return ImageData.Create (meta, PixelFormats.Bgr24, null, reader.Data, (int)meta.Width*3);
            }
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:13,代码来源:ImageKAAS.cs

示例10: Read

 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     var meta = info as EgnMetaData;
     if (null == meta)
         throw new ArgumentException ("EgnFormat.Read should be supplied with EgnMetaData", "info");
     stream.Position = meta.DataOffset;
     using (var input = new ArcView.Reader (stream))
     {
         var reader = new Reader (input, meta.UnpackedSize, meta.Mode, meta.Flag);
         reader.Unpack();
         using (var bmp = new MemoryStream (reader.Data))
             return base.Read (bmp, info);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:14,代码来源:ImageEGN.cs

示例11: Read

 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     var meta = info as QntMetaData;
     if (null == meta)
         throw new ArgumentException ("QntFormat.Read should be supplied with QntMetaData", "info");
     stream.Position = 0x44;
     using (var reader = new Reader (stream, meta))
     {
         reader.Unpack();
         int stride = (int)info.Width * (reader.BPP / 8);
         PixelFormat format = 24 == reader.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
         return ImageData.Create (info, format, null, reader.Data, stride);
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:14,代码来源:ImageQNT.cs

示例12: Read

 public override ImageData Read(Stream file, ImageMetaData info)
 {
     var meta = (WipMetaData)info;
     if (meta.FrameCount > 1)
         Trace.WriteLine ("Extra frames ignored", info.FileName);
     file.Position = 8 + 24 * meta.FrameCount;
     Color[] palette = null;
     if (8 == meta.BPP)
     {
         var palette_data = new byte[0x400];
         if (palette_data.Length != file.Read (palette_data, 0, palette_data.Length))
             throw new InvalidFormatException();
         palette = new Color[0x100];
         for (int i = 0; i < 0x100; ++i)
         {
             palette[i] = Color.FromRgb (palette_data[i*4], palette_data[i*4+1], palette_data[i*4+2]);
         }
     }
     using (var reader = new Reader (file, meta))
     {
         reader.Unpack();
         if (24 == meta.BPP)
         {
             byte[] raw = reader.Data;
             int size = (int)meta.Width * (int)meta.Height;
             byte[] pixels = new byte[size*3];
             int dst = 0;
             for (int i = 0; i < size; ++i)
             {
                 pixels[dst++] = raw[i];
                 pixels[dst++] = raw[i+size];
                 pixels[dst++] = raw[i+size*2];
             }
             return ImageData.Create (meta, PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
         }
         else if (8 == meta.BPP)
         {
             byte[] pixels = reader.Data;
             var bmp_palette = new BitmapPalette (palette);
             return ImageData.Create (meta, PixelFormats.Indexed8, bmp_palette, pixels, (int)meta.Width);
         }
         else
             throw new InvalidFormatException();
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:45,代码来源:ImageWIP.cs

示例13: ReadMetaData

 public override ImageMetaData ReadMetaData(Stream stream)
 {
     using (var input = new ArcView.Reader (stream))
     {
         int signature = ~input.ReadInt32();
         int mode = (signature & 0x70) >> 4; // v6
         if (0 != (mode & 4))
             return null;
         int flag = signature & 0xF; // v7
         int data_size, data_offset;
         if (0 != (signature & 0x80))
         {
             data_offset = 4;
             data_size = Binary.BigEndian (signature) & 0xFFFFFF;
         }
         else
         {
             data_offset = 8;
             data_size = Binary.BigEndian (input.ReadInt32());
         }
         if (data_size <= 0 || data_size > 0xFFFFFF) // arbitrary max BMP size
             return null;
         var reader = new Reader (input, 0x36, mode, flag); // size of BMP header
         reader.Unpack();
         using (var bmp = new MemoryStream (reader.Data))
         {
             var info = base.ReadMetaData (bmp);
             if (null == info)
                 return null;
             return new EgnMetaData
             {
                 Width = info.Width,
                 Height = info.Height,
                 BPP = info.BPP,
                 Mode = mode,
                 Flag = flag,
                 DataOffset = data_offset,
                 UnpackedSize = data_size,
             };
         }
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:42,代码来源:ImageEGN.cs

示例14: Read

 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     var reader = new Reader (stream, (AmMetaData)info);
     reader.Unpack();
     return ImageData.Create (info, reader.Format, reader.Palette, reader.Data);
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:6,代码来源:ImageMAI.cs

示例15: ReadPixelsData

 byte[] ReadPixelsData(Stream file, RctMetaData meta)
 {
     file.Position = meta.DataOffset + meta.AddSize;
     if (meta.IsEncrypted)
         file = OpenEncryptedStream (file, meta.DataSize);
     try
     {
         using (var reader = new Reader (file, meta))
         {
             reader.Unpack();
             return reader.Data;
         }
     }
     catch
     {
         if (meta.IsEncrypted)
             Key = null; // probably incorrect encryption scheme caused exception, reset key
         throw;
     }
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:20,代码来源:ImageRCT.cs


注:本文中的Reader.Unpack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。