Esempio n. 1
0
        // this generates 2000 files!
        static public void testGenerateAll()
        {
            long   t0 = Environment.TickCount;
            Random r  = new Random();

            for (int n = 0; n < 2000; n++)
            {
                Stream            bos = new FileStream("C:/temp/z/zlibcs" + n + ".bin", FileMode.Create);
                AZlibOutputStream ost = ZlibStreamFactory.createZlibOutputStream(bos, false);
                if (n == 0)
                {
                    Console.WriteLine("Using: " + ost);
                }
                byte[] b      = createBytes7(n < 50 ? n : n * n - 7);
                int    offset = 0;
                while (offset < b.Length)
                {
                    int len = r.Next(b.Length - offset) + 1;
                    ost.Write(b, offset, len);
                    offset += len;
                }
                ost.Close();
            }
            long t1 = Environment.TickCount;

            Console.WriteLine("generated 2000 files in " + (t1 - t0));
        }
Esempio n. 2
0
 internal static byte[] compressBytes(byte[] ori, int offset, int len, bool compress)
 {
     try
     {
         MemoryStream memoryStream = new MemoryStream(ori, offset, len);
         Stream       stream       = memoryStream;
         if (!compress)
         {
             stream = ZlibStreamFactory.createZlibInputStream(memoryStream);
         }
         MemoryStream memoryStream2 = new MemoryStream();
         Stream       stream2       = memoryStream2;
         if (compress)
         {
             stream2 = ZlibStreamFactory.createZlibOutputStream(memoryStream2);
         }
         shovelInToOut(stream, stream2);
         stream.Dispose();
         stream2.Dispose();
         return(memoryStream2.ToArray());
     }
     catch (Exception cause)
     {
         throw new PngjException(cause);
     }
 }
Esempio n. 3
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();
 }
Esempio n. 4
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);
     }
 }
Esempio n. 5
0
 public void init()
 {
     datStream         = new PngIDatChunkOutputStream(outputStream, IdatMaxSize);
     datStreamDeflated = ZlibStreamFactory.createZlibOutputStream(datStream, CompLevel, CompressionStrategy, leaveOpen: true);
     WriteSignatureAndIHDR();
     WriteFirstChunks();
 }