示例#1
0
        private static byte[] ReadBytesFromUri(Android.Net.Uri uri, Context context)
        {
            var stream          = context.ContentResolver.OpenInputStream(uri);
            var byteArrayStream = new Java.IO.ByteArrayOutputStream();

            byte[] buffer = new byte[1024];

            int i = Java.Lang.Integer.MaxValue;

            while ((i = stream.Read(buffer, 0, buffer.Length)) > 0)
            {
                byteArrayStream.Write(buffer, 0, i);
            }

            var bytes = byteArrayStream.ToByteArray();

            if (bytes.Length > (int)Common.CoreConstants.ImageSizeLimit)
            {
                return(null);
            }

            return(bytes);
        }
 public override void Write(byte[] buffer, int offset, int count)
 {
     outputStream.Write(buffer, offset, count);
 }
示例#3
0
文件: Zip.cs 项目: eatage/AppTest.bak
        /// <summary>
        /// 解压缩字符串(ICSharpCode.SharpZipLib版)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string _Decompress(string input)
        {
            string result = string.Empty;
            byte[] buffer = Convert.FromBase64String(input);

            Java.IO.ByteArrayOutputStream _out = new Java.IO.ByteArrayOutputStream();
            System.IO.Stream inputStream = new MemoryStream(buffer);
            GZIPInputStream gzip = new GZIPInputStream(inputStream);
            byte[] buff = new byte[256];
            int n = 0;
            while ((n = gzip.Read(buffer)) >= 0)
            {
                _out.Write(buffer, 0, n);
            }

            return _out.ToString();
        }