示例#1
0
 /// <summary> Called after setting data, before writing to os </summary>
 int ComputeCrc()
 {
     Zlib.CRC32 crcengine = PngHelperInternal.GetCRC();
     crcengine.Reset();
     crcengine.Update(IdBytes, 0, 4);
     if (Len > 0)
     {
         crcengine.Update(Data, 0, Len);
     }
     return((int)crcengine.GetValue());
 }
 /// <summary>
 /// Constructor must be called just after reading length and id of first IDAT
 /// chunk
 /// </summary>
 public PngIDatChunkInputStream(System.IO.Stream iStream, int lenFirstChunk, long offset_0)
 {
     this.idLastChunk     = new byte[4];
     this.toReadThisChunk = 0;
     this.ended           = false;
     this.foundChunksInfo = new System.Collections.Generic.List <IdatChunkInfo>();
     this.offset          = offset_0;
     checkCrc             = true;
     inputStream          = iStream;
     crcEngine            = new Zlib.CRC32();
     this.lenLastChunk    = lenFirstChunk;
     toReadThisChunk      = lenFirstChunk;
     // we know it's a IDAT
     System.Array.Copy(Chunks.ChunkHelper.b_IDAT, 0, idLastChunk, 0, 4);
     crcEngine.Update(idLastChunk, 0, 4);
     foundChunksInfo.Add(
         new PngIDatChunkInputStream.IdatChunkInfo(lenLastChunk, offset_0 - 8)
         );
     // PngHelper.logdebug("IDAT Initial fragment: len=" + lenLastChunk);
     if (this.lenLastChunk == 0)
     {
         EndChunkGoForNext();                // rare, but...
     }
 }