Exemple #1
0
 /// <summary>
 /// init: is called automatically before writing the first row
 /// </summary>
 private void Init()
 {
     datStream         = new PngIDatChunkOutputStream(this.outputStream, this.IdatMaxSize);
     datStreamDeflated = ZlibStreamFactory.CreateZlibOutputStream(datStream, this.CompLevel, this.CompressionStrategy, true);
     WriteSignatureAndIHDR();
     WriteFirstChunks();
 }
Exemple #2
0
 internal static byte[] CompressBytes(byte[] ori, int offset, int len, bool compress)
 {
     try
     {
         MemoryStream inb = new MemoryStream(ori, offset, len);
         Stream       inx = inb;
         if (!compress)
         {
             inx = ZlibStreamFactory.CreateZlibInputStream(inb);
         }
         MemoryStream outb = new MemoryStream();
         Stream       outx = outb;
         if (compress)
         {
             outx = ZlibStreamFactory.CreateZlibOutputStream(outb);
         }
         ShovelInToOut(inx, outx);
         inx.Close();
         outx.Close();
         byte[] res = outb.ToArray();
         return(res);
     }
     catch (Exception e)
     {
         throw new PngjException(e);
     }
 }