本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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,
};
}
}
}
示例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);
}
示例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;
}
}