当前位置: 首页>>代码示例>>C#>>正文


C# Compression类代码示例

本文整理汇总了C#中Compression的典型用法代码示例。如果您正苦于以下问题:C# Compression类的具体用法?C# Compression怎么用?C# Compression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Compression类属于命名空间,在下文中一共展示了Compression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: processImages

 private void processImages()
 {
     AzureWrapper imageazure;
     try
     {
         imageazure = new AzureWrapper(AzureStorage.VIDEO_CONTAINER_NAME);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     while (true)
     {
         try
         {
             CloudQueueMessage message = imageazure.Queue.GetMessage();
             string id = message.AsString;
             IListBlobItem blobitem = imageazure.BlobContainer.ListBlobs().Where(b => b.Uri.ToString().Contains(id)).First();
             CloudBlob blob = imageazure.BlobContainer.GetBlobReference(blobitem.Uri.ToString());
             byte[] package = blob.DownloadByteArray();
             Compression<ImageFrameSerialized> comp = new Compression<ImageFrameSerialized>();
             ImageFrameSerialized frame = comp.GZipUncompress(package);
         }
         catch (Exception ex)
         {
             string message = ex.Message;
         }
     }
 }
开发者ID:Osceus,项目名称:Kinect,代码行数:29,代码来源:WorkerRole.cs

示例2: CanDecompressFile

        public void CanDecompressFile()
        {
            var compression = new Compression();
            string value = compression.Decompress(@"Resources\commit");

            // should do better than this!
            Assert.That(value, Is.Not.Null);
        }
开发者ID:pheew,项目名称:gitsharp,代码行数:8,代码来源:CompressionTests.cs

示例3: Kinect_NewRecordedAudio

 protected override void Kinect_NewRecordedAudio(byte[] audio)
 {
     base.Kinect_NewRecordedAudio(audio);
     if (NewCompressedAudioStream != null)
     {
         Compression<byte[]> comp = new Compression<byte[]>();
         byte[] compressedValue = comp.GzipCompress(audio);
         NewCompressedAudioStream(compressedValue, audio);
     }
 }
开发者ID:Osceus,项目名称:Kinect,代码行数:10,代码来源:CompressedKinect.cs

示例4: Kinect_NewDepthFrame

        protected override void Kinect_NewDepthFrame(Depth depthImage)
        {
            base.Kinect_NewDepthFrame(depthImage);

            if (NewCompressedKinectDepthFrame != null)
            {
                Compression<DepthImageFrame> comp = new Compression<DepthImageFrame>();
                byte[] compressedVal = comp.GzipCompress(depthImage.DepthFrame);
                NewCompressedKinectDepthFrame(compressedVal, depthImage.DepthFrame);
            }
        }
开发者ID:Osceus,项目名称:Kinect,代码行数:11,代码来源:CompressedKinect.cs

示例5: ConvertCompIntoCompressOption

 public CompressionOption ConvertCompIntoCompressOption(Compression comp)
 {
     CompressionOption compress = CompressionOption.Normal;
     switch (comp)
     {
         case Compression.Normal: compress = CompressionOption.Normal; break;
         case Compression.High: compress = CompressionOption.Maximum; break;
         case Compression.Fast: compress = CompressionOption.Fast; break;
     }
     return compress;
 }
开发者ID:Habupain,项目名称:UniBackup,代码行数:11,代码来源:ZipManager.cs

示例6: Kinect_NewSkeletonFrame

        protected override void Kinect_NewSkeletonFrame(Skel skeletonImage)
        {
            base.Kinect_NewSkeletonFrame(skeletonImage);

            if (NewCompressedSkeletonFrame != null)
            {
                Compression<SkeletonFrame> comp = new Compression<SkeletonFrame>();
                byte[] compressedVal = comp.GzipCompress(skeletonImage.Skeleton);
                NewCompressedSkeletonFrame(compressedVal, skeletonImage.Skeleton);
            }
        }
开发者ID:Osceus,项目名称:Kinect,代码行数:11,代码来源:CompressedKinect.cs

示例7: Create

 public static IIndexSerializer Create(Compression compression)
 {
     switch (compression)
     {
         case Compression.No:
             return new SimpleIndexSerializer();
         case Compression.Yes:
             return new CompressingIndexSerializer(new StreamFactory(), new VariableByteNumberEncoder(),
                 new NumberLengthReducer());
         default:
             throw new ArgumentOutOfRangeException(nameof(compression), compression, "Unknown compression type");
     }
 }
开发者ID:AndriyKhavro,项目名称:InformationRetrieval,代码行数:13,代码来源:IndexSerializerFactory.cs

示例8: WriteToDisk

        public static void WriteToDisk(ushort[][] data, String fileName, int imageWidth, int imageHeight, int samplesPerPixel = 1, Compression compression = Compression.NONE, int bitsPerSample = 16)
        {
            if (data == null)
                throw new Exception("no data provided");

            using (Tiff imagesData = Tiff.Open(fileName, "w"))
            {
                for (uint page = 0; page < data.Length; page++)
                {
                    imagesData.SetField(TiffTag.IMAGEWIDTH, imageWidth.ToString(CultureInfo.InvariantCulture));
                    imagesData.SetField(TiffTag.IMAGELENGTH, imageHeight.ToString(CultureInfo.InvariantCulture));
                    imagesData.SetField(TiffTag.COMPRESSION, compression);
                    imagesData.SetField(TiffTag.BITSPERSAMPLE, bitsPerSample.ToString(CultureInfo.InvariantCulture));
            //                imageData.SetField(TiffTag.SAMPLESPERPIXEL, samplesPerPixel);
                    imagesData.SetField(TiffTag.XRESOLUTION, 1);
                    imagesData.SetField(TiffTag.YRESOLUTION, 1);
                    imagesData.SetField(TiffTag.DATETIME, DateTime.Now);
            //                imageData.SetField(TiffTag.ROWSPERSTRIP, imageHeight.ToString(CultureInfo.InvariantCulture));
                    imagesData.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
                    imagesData.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
                    imagesData.SetField(TiffTag.FILLORDER, FillOrder.MSB2LSB);
                    imagesData.SetField(TiffTag.ORIENTATION, Orientation.TOPLEFT);
                    imagesData.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.CENTIMETER);

                    imagesData.SetField(TiffTag.ARTIST, "ProjectStorm");
                    imagesData.SetField(TiffTag.IMAGEDESCRIPTION, "Test data constructed by openCL kernel of project storm");

                    // specify that it's a page within the multipage file
                    imagesData.SetField(TiffTag.SUBFILETYPE, FileType.PAGE);
                    // specify the page number
                    imagesData.SetField(TiffTag.PAGENUMBER, page, data.Length);

                    for (int i = 0; i < imageHeight; i++)
                    {
                        Byte[] buffer = new byte[data[page].Length * sizeof(ushort)];

                        Buffer.BlockCopy(data, i * imageWidth, buffer, 0, buffer.Length);
                        imagesData.WriteScanline(buffer, i);
                    }

                    imagesData.WriteDirectory();
                }

                imagesData.FlushData();
            }
        }
开发者ID:jalmar,项目名称:DoM_Utrecht-GPU,代码行数:46,代码来源:TiffData.cs

示例9: RetrieveAlbumByName

        public Album RetrieveAlbumByName(IDBClient db, string albumName, Compression compression)
        {
            var db4oClient = db as Db4oClient;

            // search for the album
            if (db4oClient != null)
            {
                IEnumerable<Album> result = from Album a in db4oClient.Client
                                            where a.Title == albumName &&
                                                  a.Compression.Equals(compression)
                                            select a;

                // return the first one if anything returned
                if (result.Count() > 0)
                {
                    return result.ToArray()[0];
                }
            }
            return null;
        }
开发者ID:thenathanjones,项目名称:propaganda_win,代码行数:20,代码来源:Db4oAudioDB.cs

示例10: CompressPacket

        public static ServerPacket CompressPacket(Packet packet)
        {
            // We need the opcode as uint.
            var msg = BitConverter.GetBytes((uint)packet.Header.Message);

            packet.Data[0] = msg[0];
            packet.Data[1] = msg[1];
            packet.Data[2] = msg[2];
            packet.Data[3] = msg[3];

            var compression = new Compression
            {
                UncompressedSize = packet.Data.Length,
                UncompressedAdler = Helper.Adler32(packet.Data)
            };

            // Compress.
            using (var ms = new MemoryStream())
            {
                using (var ds = new DeflateStream(ms, CompressionLevel.Fastest))
                {
                    ds.Write(packet.Data, 0, packet.Data.Length);
                    ds.Flush();
                }

                compression.CompressedData = ms.ToArray();
            }

            compression.CompressedData[0] -= 1;

            if ((compression.CompressedData[compression.CompressedData.Length - 1] & 8) == 8)
                compression.CompressedData = compression.CompressedData.Combine(new byte[1]);

            compression.CompressedData = compression.CompressedData.Combine(new byte[] { 0x00, 0x00, 0xFF, 0xFF });
            compression.CompressedAdler = Helper.Adler32(compression.CompressedData);

            return compression;
        }
开发者ID:LuigiElleBalotta,项目名称:ElleServer,代码行数:38,代码来源:NetHandler.cs

示例11: Copy

        public bool Copy(Tiff inImage, Tiff outImage)
        {
            int width = 0;
            FieldValue[] result = inImage.GetField(TiffTag.IMAGEWIDTH);
            if (result != null)
            {
                width = result[0].ToInt();
                outImage.SetField(TiffTag.IMAGEWIDTH, width);
            }

            int length = 0;
            result = inImage.GetField(TiffTag.IMAGELENGTH);
            if (result != null)
            {
                length = result[0].ToInt();
                outImage.SetField(TiffTag.IMAGELENGTH, length);
            }

            short bitspersample = 1;
            result = inImage.GetField(TiffTag.BITSPERSAMPLE);
            if (result != null)
            {
                bitspersample = result[0].ToShort();
                outImage.SetField(TiffTag.BITSPERSAMPLE, bitspersample);
            }

            short samplesperpixel = 1;
            result = inImage.GetField(TiffTag.SAMPLESPERPIXEL);
            if (result != null)
            {
                samplesperpixel = result[0].ToShort();
                outImage.SetField(TiffTag.SAMPLESPERPIXEL, samplesperpixel);
            }

            if (m_compression != (Compression)(-1))
                outImage.SetField(TiffTag.COMPRESSION, m_compression);
            else
            {
                result = inImage.GetField(TiffTag.COMPRESSION);
                if (result != null)
                {
                    m_compression = (Compression)result[0].ToInt();
                    outImage.SetField(TiffTag.COMPRESSION, m_compression);
                }
            }

            result = inImage.GetFieldDefaulted(TiffTag.COMPRESSION);
            Compression input_compression = (Compression)result[0].ToInt();

            result = inImage.GetFieldDefaulted(TiffTag.PHOTOMETRIC);
            Photometric input_photometric = (Photometric)result[0].ToShort();
    
            if (input_compression == Compression.JPEG)
            {
                /* Force conversion to RGB */
                inImage.SetField(TiffTag.JPEGCOLORMODE, JpegColorMode.RGB);
            }
            else if (input_photometric == Photometric.YCBCR)
            {
                /* Otherwise, can't handle subsampled input */
                result = inImage.GetFieldDefaulted(TiffTag.YCBCRSUBSAMPLING);
                short subsamplinghor = result[0].ToShort();
                short subsamplingver = result[1].ToShort();

                if (subsamplinghor != 1 || subsamplingver != 1)
                {
                    Console.Error.WriteLine("tiffcp: {0}: Can't copy/convert subsampled image.", inImage.FileName());
                    return false;
                }
            }

            if (m_compression == Compression.JPEG)
            {
                if (input_photometric == Photometric.RGB && m_jpegcolormode == JpegColorMode.RGB)
                    outImage.SetField(TiffTag.PHOTOMETRIC, Photometric.YCBCR);
                else
                    outImage.SetField(TiffTag.PHOTOMETRIC, input_photometric);
            }
            else if (m_compression == Compression.SGILOG || m_compression == Compression.SGILOG24)
            {
                outImage.SetField(TiffTag.PHOTOMETRIC, samplesperpixel == 1 ? Photometric.LOGL : Photometric.LOGLUV);
            }
            else
            {
                if (input_compression != Compression.JPEG)
                    copyTag(inImage, outImage, TiffTag.PHOTOMETRIC, 1, TiffType.SHORT);
            }

            if (m_fillorder != 0)
                outImage.SetField(TiffTag.FILLORDER, m_fillorder);
            else
                copyTag(inImage, outImage, TiffTag.FILLORDER, 1, TiffType.SHORT);

            /*
             * Will copy `Orientation' tag from input image
             */
            result = inImage.GetFieldDefaulted(TiffTag.ORIENTATION);
            m_orientation = (Orientation)result[0].ToByte();
            switch (m_orientation)
            {
//.........这里部分代码省略.........
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:101,代码来源:Copier.cs

示例12: ProcessCompressOptions

        public bool ProcessCompressOptions(string opt)
        {
            if (opt == "none")
            {
                m_defcompression = Compression.NONE;
            }
            else if (opt == "packbits")
            {
                m_defcompression = Compression.PACKBITS;
            }
            else if (opt.StartsWith("jpeg"))
            {
                m_defcompression = Compression.JPEG;

                string[] options = opt.Split(new char[] { ':' });
                for (int i = 1; i < options.Length; i++)
                {
                    if (char.IsDigit(options[i][0]))
                        m_quality = int.Parse(options[i], CultureInfo.InvariantCulture);
                    else if (options[i] == "r")
                        m_jpegcolormode = JpegColorMode.RAW;
                    else
                        return false;
                }
            }
            else if (opt.StartsWith("g3"))
            {
                if (!processG3Options(opt))
                    return false;

                m_defcompression = Compression.CCITTFAX3;
            }
            else if (opt == "g4")
            {
                m_defcompression = Compression.CCITTFAX4;
            }
            else if (opt.StartsWith("lzw"))
            {
                int n = opt.IndexOf(':');
                if (n != -1 && n < (opt.Length - 1))
                    m_defpredictor = short.Parse(opt.Substring(n + 1));

                m_defcompression = Compression.LZW;
            }
            else if (opt.StartsWith("zip"))
            {
                int n = opt.IndexOf(':');
                if (n != -1 && n < (opt.Length - 1))
                    m_defpredictor = short.Parse(opt.Substring(n + 1));

                m_defcompression = Compression.ADOBE_DEFLATE;
            }
            else
                return false;

            return true;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:57,代码来源:Copier.cs

示例13: send_prepare_cql3_query

 public void send_prepare_cql3_query(byte[] query, Compression compression)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("prepare_cql3_query", TMessageType.Call, seqid_));
   prepare_cql3_query_args args = new prepare_cql3_query_args();
   args.Query = query;
   args.Compression = compression;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
开发者ID:achinn,项目名称:fluentcassandra,代码行数:15,代码来源:Cassandra.cs

示例14: FindCodec

        /// <summary>
        /// Retrieves the codec registered for the specified compression scheme.
        /// </summary>
        /// <param name="scheme">The compression scheme.</param>
        /// <returns>The codec registered for the specified compression scheme or <c>null</c>
        /// if there is no codec registered for the given scheme.</returns>
        /// <remarks>
        /// <para>
        /// LibTiff.Net supports a variety of compression schemes implemented by software codecs.
        /// Each codec adheres to a modular interface that provides for the decoding and encoding
        /// of image data; as well as some other methods for initialization, setup, cleanup, and
        /// the control of default strip and tile sizes. Codecs are identified by the associated
        /// value of the <see cref="TiffTag"/>.Compression tag.
        /// </para>
        /// <para>
        /// Other compression schemes may be registered. Registered schemes can also override the
        /// built-in versions provided by the library.
        /// </para>
        /// </remarks>
        public TiffCodec FindCodec(Compression scheme)
        {
            for (codecList list = m_registeredCodecs; list != null; list = list.next)
            {
                if (list.codec.m_scheme == scheme)
                    return list.codec;
            }

            for (int i = 0; m_builtInCodecs[i] != null; i++)
            {
                TiffCodec codec = m_builtInCodecs[i];
                if (codec.m_scheme == scheme)
                    return codec;
            }

            return null;
        }
开发者ID:Orvid,项目名称:Cosmos,代码行数:36,代码来源:LibTiff.cs

示例15: TiffCodec

 /// <summary>
 /// Initializes a new instance of the <see cref="TiffCodec"/> class.
 /// </summary>
 /// <param name="tif">An instance of <see cref="Tiff"/> class.</param>
 /// <param name="scheme">The compression scheme for the codec.</param>
 /// <param name="name">The name of the codec.</param>
 public TiffCodec(Tiff tif, Compression scheme, string name)
 {
     m_scheme = scheme;
     m_tif = tif;
     m_name = name;
 }
开发者ID:Orvid,项目名称:Cosmos,代码行数:12,代码来源:LibTiff.cs


注:本文中的Compression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。