//Stopwatch st;
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            //st.Start();
            base.OnActivityResult(requestCode, resultCode, data);
            LoggingClass.LogInfo("Entered into ProfilePictureGallery", screenid);
            if (resultCode == Result.Ok)
            {
                string Path = GetRealPathFromURI(data.Data);
                try
                {
                    Bitmap propic = BitmapFactory.DecodeFile(Path);
                    ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
                    string dir_path = pppd.CreateDirectoryForPictures();
                    dir_path = dir_path + "/" + Convert.ToInt32(CurrentUser.getUserId()) + ".jpg";
                    ProfileActivity pa       = new ProfileActivity();
                    Bitmap          resized  = pa.Resize(propic, 400, 400);
                    var             filePath = System.IO.Path.Combine(dir_path);
                    var             stream   = new FileStream(filePath, FileMode.Create);
                    resized.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                    stream.Close();
                    pppd.UploadProfilePic(filePath);
                    Intent intent = new Intent(this, typeof(TabActivity));
                    StartActivity(intent);
                }

                catch (Exception exe)
                {
                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                }
            }
            //st.Stop();
            //LoggingClass.LogTime("profile pic gall time", st.Elapsed.TotalSeconds.ToString());
        }
        public void resize()
        {
            Bitmap          propic  = BitmapFactory.DecodeFile(path);
            ProfileActivity pa      = new ProfileActivity();
            Bitmap          resized = pa.resizeAndRotate(propic, 450, 450);

            try
            {
                var filePath = System.IO.Path.Combine(path);
                var stream   = new FileStream(filePath, FileMode.Create);
                resized.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                stream.Close();
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 3
0
        public void Resize()
        {
            try
            {
                Bitmap          propic  = BitmapFactory.DecodeFile(path);
                ProfileActivity pa      = new ProfileActivity();
                Bitmap          resized = pa.ResizeAndRotate(propic, 400, 400);

                var filePath = System.IO.Path.Combine(path);
                var stream   = new FileStream(filePath, FileMode.Create);
                resized.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                stream.Close();
                propic.Dispose();
                resized.Dispose();
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
            }
        }
Ejemplo n.º 4
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == Result.Ok)
            {
                //var imageView =
                //    FindViewById<ImageView>(Resource.Id.imageView1);
                //imageView.SetImageURI(data.Data);

                // new FileInfo(path).Directory.FullName
                string Path = GetRealPathFromURI(data.Data);


                Bitmap propic = BitmapFactory.DecodeFile(Path);

                ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
                string dir_path = pppd.CreateDirectoryForPictures();
                dir_path = dir_path + "/" + Convert.ToInt32(CurrentUser.getUserId()) + ".jpg";
                ProfileActivity pa      = new ProfileActivity();
                Bitmap          resized = pa.Resize(propic, 450, 450);
                try
                {
                    var filePath = System.IO.Path.Combine(dir_path);
                    var stream   = new FileStream(filePath, FileMode.Create);
                    resized.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                    stream.Close();
                    Toast.MakeText(this, "Thank you,We will update your profile picture as soon as possible", ToastLength.Short).Show();
                    Toast.MakeText(this, "Please touch anywhere to exit this dialog.", ToastLength.Short).Show();
                    pppd.UploadProfilePic(filePath);
                }
                catch (Exception ex)
                {
                }
            }
        }