本文整理汇总了C#中IList.Sub方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Sub方法的具体用法?C# IList.Sub怎么用?C# IList.Sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Sub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AbstractSprite
protected AbstractSprite( IList<byte> bytes, params IList<byte>[] extraBytes )
: this()
{
OriginalSize = bytes.Count;
Palettes = BuildPalettes( bytes.Sub( 0, 16 * 32 - 1 ) );
Pixels = BuildPixels( bytes.Sub( 16 * 32 ), extraBytes );
}
示例2: DirectoryEntry
public DirectoryEntry( IList<byte> bytes )
{
System.Diagnostics.Debug.Assert( bytes[0] == bytes.Count );
Sector = bytes.Sub( 2, 2 + 4 - 1 ).ToUInt32();
Size = bytes.Sub( 10, 10 + 4 - 1 ).ToUInt32();
Timestamp = new DateTime( bytes[18] + 1900, bytes[19], bytes[20], bytes[21], bytes[22], bytes[23] );
GMTOffset = bytes[24];
MiddleBytes = bytes.Sub( 25, 25 + 7 - 1 ).ToArray();
byte nameLength = bytes[32];
Filename = System.Text.Encoding.ASCII.GetString( bytes.Sub( 33, 33 + nameLength - 1 ).ToArray() );
byte padding = (byte)(((nameLength % 2) == 0) ? 1 : 0);
ExtendedBytes = bytes.Sub( 33 + nameLength + padding, bytes[0] - 1 ).ToArray();
}
示例3: BuildPixels
protected override IList<byte> BuildPixels( IList<byte> bytes, IList<byte>[] extraBytes )
{
List<byte> result = new List<byte>( 36864 * 2 );
foreach( byte b in bytes.Sub( 0, 36864 - 1 ) )
{
result.Add( b.GetLowerNibble() );
result.Add( b.GetUpperNibble() );
}
result.AddRange( Decompress( bytes.Sub( 36864 ) ) );
result.AddRange( new byte[Math.Max( 0, 488 * 256 - result.Count )] );
return result.ToArray();
}
示例4: Shape
private Shape( IList<byte> bytes, string name, Rectangle relevantRectangle )
{
RelevantRectangle = relevantRectangle;
this.name = name;
int jump = (int)bytes.Sub( 0, 3 ).ToUInt32();
int secondHalf = bytes[4] + bytes[5] * 256;
List<uint> offsets = new List<uint>();
offsets.Add( 0 );
uint addy = 0;
int i =0 ;
do
{
addy = bytes.Sub( 0x0C + 4 * i, 0x0C + 4 * i + 3 ).ToUInt32();
i++;
if( addy != 0 )
{
offsets.Add( addy );
}
} while( addy != 0 );
frames = new List<Frame>( offsets.Count );
for( i = 0; i < offsets.Count; i++ )
{
frames.Add( new Frame( bytes.Sub( (int)(offsets[i] + 0x40A) ), i >= secondHalf ? 256 : 0 ) );
}
if( jump > 8 )
{
offsets = new List<uint>();
offsets.Add( 0 );
addy = 0;
i = 0;
do
{
addy = bytes.Sub( jump + 4 * i + 4, jump + 4 * i + 3 + 4 ).ToUInt32();
i++;
if( addy != 0 )
{
offsets.Add( addy );
}
} while( addy != 0 );
}
for( i = 0; i < offsets.Count; i++ )
{
frames.Add( new Frame( bytes.Sub( (int)(offsets[i] + jump + 0x402) ), i >= secondHalf ? 256 : 0 ) );
}
}
示例5: PartitionedFile
public PartitionedFile( GenericCharMap map, FFTPatcher.TextEditor.FFTTextFactory.FileInfo layout, IList<byte> bytes )
: base( map, layout, false )
{
PartitionSize = layout.Size / NumberOfSections;
List<IList<string>> sections = new List<IList<string>>( NumberOfSections );
for ( int i = 0; i < NumberOfSections; i++ )
{
sections.Add(TextUtilities.ProcessList(bytes.Sub(i * PartitionSize, (i + 1) * PartitionSize - 1), map));
if ( sections[i].Count < SectionLengths[i] )
{
string[] newSection = new string[SectionLengths[i]];
sections[i].CopyTo( newSection, 0 );
new string[SectionLengths[i] - sections[i].Count].CopyTo( newSection, sections[i].Count );
sections[i] = newSection;
}
else if (sections[i].Count > SectionLengths[i])
{
sections[i] = sections[i].Sub(0, SectionLengths[i] - 1);
}
System.Diagnostics.Debug.Assert(sections[i].Count == SectionLengths[i]);
}
Sections = sections.AsReadOnly();
PopulateDisallowedSections();
}
示例6: OPNBK
public OPNBK( IList<byte> bytes )
{
const int start0 = 0;
const int end0 = 320 * 240 * 2 - 1;
const int start1 = end0 + 1;
const int end1 = start1 + 256 * 240 * 2 - 1;
const int start2 = end1 + 1;
const int end2 = start2 + 210 * 180 * 2 - 1;
const int start3 = end2 + 1;
const int end3 = start3 + 210 * 180 * 2 - 1;
const int start4 = end3 + 1;
const int end4 = start4 + 210 * 180 * 2 - 1;
const int start5 = end4 + 1;
const int end5 = start5 + 210 * 180 * 2 - 1;
const int start6 = end5 + 1;
const int end6 = start6 + 512 * 240 * 2 - 1;
images = new Image[7];
images[0] = Utilities.ReadBytesAsRawImage( bytes.Sub( start0, end0 ), 320, 240 ).ToImage();
images[1] = Utilities.ReadBytesAsRawImage( bytes.Sub( start1, end1 ), 256, 240 ).ToImage();
images[2] = Utilities.ReadBytesAsRawImage( bytes.Sub( start2, end2 ), 210, 180 ).ToImage();
images[3] = Utilities.ReadBytesAsRawImage( bytes.Sub( start3, end3 ), 210, 180 ).ToImage();
images[4] = Utilities.ReadBytesAsRawImage( bytes.Sub( start4, end4 ), 210, 180 ).ToImage();
images[5] = Utilities.ReadBytesAsRawImage( bytes.Sub( start5, end5 ), 210, 180 ).ToImage();
images[6] = Utilities.ReadBytesAsRawImage( bytes.Sub( start6, end6 ), 512, 240 ).ToImage();
}
示例7: EVTCHR
public EVTCHR(IList<byte> bytes)
{
System.Diagnostics.Debug.Assert(bytes.Count == numSegments * Segment.NumBytes);
segments = new Segment[numSegments];
for (int i = 0; i < numSegments; i++)
{
segments[i] = new Segment(bytes.Sub(i * Segment.NumBytes, (i + 1) * Segment.NumBytes - 1));
}
}
示例8: Frame
public Frame( IList<byte> bytes, int yOffset )
{
int numberOfTiles = bytes[0] + bytes[1] * 256;
tiles = new List<Tile>( numberOfTiles + 1 );
for( int i = 0; i <= numberOfTiles; i++ )
{
tiles.Add( new Tile( bytes.Sub( 2 + i * 4, 2 + i * 4 + 3 ), yOffset ) );
}
tiles.Reverse();
}
示例9: ENTD
public ENTD( int start, IList<byte> bytes, ENTD defaults )
{
Default = defaults;
Events = new Event[0x80];
for( int i = 0; i < 0x80; i++ )
{
Events[i] = new Event(
i + start,
bytes.Sub( i * 16 * 40, (i + 1) * 16 * 40 - 1 ),
defaults == null ? null : defaults.Events[i] );
}
}
示例10: BuildPixels
protected override IList<byte> BuildPixels(IList<byte> bytes, params IList<byte>[] extraBytes)
{
List<byte> result = new List<byte>(36864 * 2);
foreach (byte b in bytes.Sub(0, 36863))
{
result.Add(b.GetLowerNibble());
result.Add(b.GetUpperNibble());
}
result.AddRange(Decompress(bytes.Sub(36864)));
foreach (IList<byte> extra in extraBytes)
{
foreach (byte b in extra)
{
result.Add(b.GetLowerNibble());
result.Add(b.GetUpperNibble());
}
}
return result.ToArray();
}
示例11: SectionedFile
public SectionedFile( GenericCharMap map, FFTPatcher.TextEditor.FFTTextFactory.FileInfo layout, IList<byte> bytes, string fileComments, IList<string> sectionComments, bool compressible )
: base(map, layout, fileComments, sectionComments, compressible)
{
List<IList<string>> sections = new List<IList<string>>( NumberOfSections );
for ( int i = 0; i < NumberOfSections; i++ )
{
uint start = PatcherLib.Utilities.Utilities.BytesToUInt32( bytes.Sub( i * 4, ( i + 1 ) * 4 - 1 ) );
uint stop = PatcherLib.Utilities.Utilities.BytesToUInt32( bytes.Sub( ( i + 1 ) * 4, ( i + 2 ) * 4 - 1 ) ) - 1;
if ( i == NumberOfSections - 1 )
{
stop = (uint)bytes.Count - 1 - (uint)DataStart;
}
IList<byte> thisSection = bytes.Sub( (int)( start + DataStart ), (int)( stop + DataStart ) );
if ( compressible )
{
thisSection = TextUtilities.Decompress( bytes, thisSection, (int)( start + DataStart ) );
}
sections.Add( TextUtilities.ProcessList( thisSection, layout.AllowedTerminators[0], CharMap ) );
}
Sections = sections.AsReadOnly();
PopulateDisallowedSections();
}
示例12: FFTFont
public FFTFont( IList<byte> bytes, IList<byte> widthBytes )
{
GlyphWidths = new FFTFontWidths( this );
Glyphs = new Glyph[2200];
for( int i = 0; i < 2200; i++ )
{
Glyphs[i] = new Glyph( i, widthBytes[i], bytes.Sub( i * 35, (i + 1) * 35 - 1 ) );
}
#if DEBUG
using ( System.Drawing.Bitmap b = new System.Drawing.Bitmap( 550, 560 ) )
{
for ( int i = 0; i < 2200; i++ )
{
DrawGlyphOnBitmap( b, Glyphs[i], new System.Drawing.Point( 10 * ( i % 55 ), 14 * ( i / 55 ) ) );
}
b.Save( "font.png", System.Drawing.Imaging.ImageFormat.Png );
}
#endif
}
示例13: Frame
public Frame( IList<byte> bytes, int yOffset,string name )
{
int rotation = 0;
int ydisplayoffset = 0;
int numberOfTiles = bytes[0] + bytes[1] * 256;
if (name == "WEP1" || name == "WEP2" ||name == "EFF1" || name == "EFF2" )
{
numberOfTiles = 0;
rotation = bytes[0] + bytes[1] * 256;
ydisplayoffset = bytes[0] / 4;
}
tiles = new List<Tile>( numberOfTiles + 1 );
for( int i = 0; i <= numberOfTiles; i++ )
{
tiles.Add( new Tile( bytes.Sub( 2 + i * 4, 2 + i * 4 + 3 ), yOffset,rotation) );
}
tiles.Reverse();
}
示例14: PartitionedFile
public PartitionedFile( GenericCharMap map, FFTPatcher.TextEditor.FFTTextFactory.FileInfo layout, IList<byte> bytes, string fileComments, IList<string> sectionComments )
: base(map, layout, fileComments, sectionComments, false)
{
PartitionSize = layout.Size / NumberOfSections;
List<IList<string>> sections = new List<IList<string>>( NumberOfSections );
for ( int i = 0; i < NumberOfSections; i++ )
{
sections.Add(TextUtilities.ProcessList(bytes.Sub(i * PartitionSize, (i + 1) * PartitionSize - 1), layout.AllowedTerminators, map));
if ( sections[i].Count < SectionLengths[i] )
{
string[] newSection = new string[SectionLengths[i]];
sections[i].CopyTo( newSection, 0 );
new string[SectionLengths[i] - sections[i].Count].CopyTo( newSection, sections[i].Count );
sections[i] = newSection;
}
else if (sections[i].Count > SectionLengths[i])
{
sections[i] = sections[i].Sub(0, SectionLengths[i] - 1);
}
if (layout.AllowedTerminators.Count > 1)
{
Dictionary<byte, int> counts = new Dictionary<byte, int>();
layout.AllowedTerminators.ForEach(b => counts[b] = 0);
bytes.FindAll(b => layout.AllowedTerminators.Contains(b)).ForEach(b => counts[b]++);
List<KeyValuePair<byte, int>> countList = new List<KeyValuePair<byte, int>>(counts);
countList.Sort((a, b) => b.Value.CompareTo(a.Value));
this.SelectedTerminator = countList[0].Key;
}
System.Diagnostics.Debug.Assert(sections[i].Count == SectionLengths[i]);
}
Sections = sections.AsReadOnly();
PopulateDisallowedSections();
}
示例15: ProcessPage
private void ProcessPage( int page, IList<byte> bytes )
{
int startIndex = page * portraitsPerPage;
IList<byte> truePixels = GetTruePixels( bytes.Sub( 0, portraitsPerPage * portraitWidth * portraitHeight / 2 ) );
for ( int i = 0; i < portraitsPerPage; i++ )
{
Palettes[page * portraitsPerPage + i] = new Palette(
bytes.Sub(
i * paletteSize + portraitsPerPage * portraitWidth * portraitHeight / 2,
( i + 1 ) * paletteSize + portraitsPerPage * portraitWidth * portraitHeight / 2 - 1 ) );
}
for ( int row = 0; row < rowsPerPage; row++ )
{
for ( int col = 0; col < colsPerPage; col++ )
{
Bitmap b = new Bitmap( portraitWidth, portraitHeight, PixelFormat.Format4bppIndexed );
ColorPalette p = b.Palette;
Palette.FixupColorPalette( p, Palettes, startIndex + row * col, 0 );
b.Palette = p;
BitmapData bmd = b.LockBits( new Rectangle( Point.Empty, b.Size ), ImageLockMode.WriteOnly, PixelFormat.Format4bppIndexed );
int xOffset = col * portraitWidth;
int yOffset = row * portraitHeight;
for ( int x = 0; x < portraitWidth; x++ )
{
for ( int y = 0; y < portraitHeight; y++ )
{
bmd.SetPixel4bpp( x, y, truePixels[xOffset + x + ( yOffset + y ) * portraitWidth * colsPerPage] );
}
}
b.UnlockBits( bmd );
Images[startIndex + row * colsPerPage + col] = b;
b.Save( string.Format( "{0}.png", startIndex + row * colsPerPage + col ), ImageFormat.Png );
}
}
}