コード例 #1
0
        void IPreviewCallback.OnPreviewFrame(byte[] b, Camera c)
        {
            Android.Graphics.YuvImage yuvImage = new Android.Graphics.YuvImage(b, Android.Graphics.ImageFormat.Nv21, previewSize.Width, previewSize.Height, null);
            byte[]       msg = new byte[65000];
            MemoryStream ms  = new MemoryStream();

            yuvImage.CompressToJpeg(new Android.Graphics.Rect(0, 0, previewSize.Width, previewSize.Height), 100, ms);

            Deflater compresser = new Deflater();

            compresser.SetInput(ms.ToArray());
            compresser.Finish();
            compresser.Deflate(msg);             //int length = compresser.Deflate(msg);
            compresser.End();

            var current = Connectivity.NetworkAccess;

            if (current == Xamarin.Essentials.NetworkAccess.Internet)
            {
                try
                {
                    Sock.SendTo(msg, EndP);
                }
                catch
                {
                }
            }
            Thread.Sleep(300);
        }
コード例 #2
0
        /// <summary>
        /// Writes remaining compressed data to the output stream and closes the
        /// underlying stream. </summary>
        /// <exception cref="IOException"> if an I/O error has occurred </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void close() throws java.io.IOException
        public override void Close()
        {
            if (!Closed)
            {
                Finish();
                if (UsesDefaultDeflater)
                {
                    Def.End();
                }
                @out.Close();
                Closed = true;
            }
        }