Exemplo n.º 1
0
        private void RotateImage()
        {
            if (this.rotatedBitmap == null)
            {
                ArticleImage article = Database.GetArticleImage(this.articleId, true);
                if (article == null)
                {
                    return;
                }

                if (article.ImageLarge == null)
                {
                    return;
                }
                try
                {
                    this.rotatedBitmap = BitmapFactory.DecodeByteArray(article.ImageLarge, 0, article.ImageLarge.Length);
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    TRACE(ex);

                    this.rotatedBitmap = null;
                    this.imageView.SetImageResource(Resource.Drawable.baseline_error_outline_black_24);
                    this.imageView.Alpha = 1f;
                    this.imageInfo.Text  = ex.Message;
                    return;
                }
            }

            try
            {
                // Bild um 90 Grad drehen
                Matrix mat = new Matrix();
                mat.PostRotate(90);
                Bitmap bMapRotate = Bitmap.CreateBitmap(this.rotatedBitmap, 0, 0, this.rotatedBitmap.Width, this.rotatedBitmap.Height, mat, true);
                this.imageView.SetImageBitmap(bMapRotate);
                this.rotatedBitmap = bMapRotate;
                this.isChanged     = true;

                string message = string.Format("Bild (BxH): {0:n0} X {1:n0} (Größe: {2:n0})",
                                               this.rotatedBitmap.Width,
                                               this.rotatedBitmap.Height,
                                               Tools.ToFuzzyByteString(this.rotatedBitmap.ByteCount));

                this.imageInfo.Text = message;
            }
            catch (Exception ex)
            {
                TRACE(ex);

                this.rotatedBitmap = null;
                this.imageView.SetImageResource(Resource.Drawable.baseline_error_outline_black_24);
                this.imageView.Alpha = 1f;
                this.imageInfo.Text  = ex.Message;
            }
        }
        private void ShowPictureFromDatabase()
        {
            if (this.articleId == 0)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_white_24dp);
                this.imageView.Alpha = 1f;
                return;
            }

            ArticleImage article = Database.GetArticleImage(this.articleId, true);

            if (article == null)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_black_24dp);
                this.imageView.Alpha = 0.5f;

                return;
            }

            if (article.ImageLarge == null)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_black_24dp);
                this.imageView.Alpha = 0.5f;

                return;
            }

            string message = string.Empty;

            try
            {
                Bitmap image = BitmapFactory.DecodeByteArray(article.ImageLarge, 0, article.ImageLarge.Length);

                this.imageView.SetImageBitmap(image);

                message = string.Format("Bild: {0:n0} X {1:n0} (Größe: {2:n0}, Komprimiert: {3:n0})",
                                        image.Height,
                                        image.Width,
                                        Tools.ToFuzzyByteString(image.ByteCount),
                                        Tools.ToFuzzyByteString(article.ImageLarge.Length));

                image = null;
            }
            catch (Exception e)
            {
                message = e.Message;
                this.imageView.SetImageResource(Resource.Drawable.baseline_error_outline_black_24);
                this.imageView.Alpha = 1f;
            }

            this.imageInfo.Text = message;
            article             = null;
        }
Exemplo n.º 3
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if ((requestCode == ArticleDetailId) && (resultCode == Result.Ok))
            {
                StorageItemQuantityActivity.article      = null;
                StorageItemQuantityActivity.articleImage = null;
                this.ShowPictureAndDetails(this.articleId, this.text);
                this.isChanged = true;
            }
        }
Exemplo n.º 4
0
        private void ShowPictureAndDetails(int articleId, string title)
        {
            var headerView = FindViewById <TextView>  (Resource.Id.StorageItemQuantity_ArticleDetailHeader);
            var imageView  = FindViewById <ImageView> (Resource.Id.StorageItemQuantity_Image);
            var detailView = FindViewById <TextView>  (Resource.Id.StorageItemQuantity_ArticleDetail);

            if (articleId == 0)
            {
                headerView.Text = title;
                detailView.Text = "Details zum " + title;
                imageView.SetImageResource(Resource.Drawable.ic_add_a_photo_white_24dp);

                return;
            }
            try
            {
                if (StorageItemQuantityActivity.article == null)
                {
                    StorageItemQuantityActivity.article = Database.GetArticle(articleId);
                }

                if (StorageItemQuantityActivity.articleImage == null)
                {
                    StorageItemQuantityActivity.articleImage = Database.GetArticleImage(articleId, false);
                }

                Article article = StorageItemQuantityActivity.article;

                this.durableInfinity = article.DurableInfinity;

                ArticleListView articleView = new ArticleListView(article);

                headerView.Text = articleView.Heading;
                detailView.Text = articleView.SubHeading;
                if (!string.IsNullOrEmpty(articleView.Notes))
                {
                    detailView.Text += "\n";
                    detailView.Text += articleView.Notes;
                }

                this.ShowPicture(detailView, imageView);
            }
            catch (Exception ex)
            {
                TRACE(ex);

                imageView.SetImageResource(Resource.Drawable.baseline_error_outline_black_24);
                headerView.Text = null;
                detailView.Text = ex.Message + ex.StackTrace;
            }
        }
Exemplo n.º 5
0
 public static void Reload()
 {
     StorageItemQuantityActivity.liste        = null;
     StorageItemQuantityActivity.article      = null;
     StorageItemQuantityActivity.articleImage = null;
 }
Exemplo n.º 6
0
        private void ShowPictureFromDatabase()
        {
            if (this.articleId == 0)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_white_24dp);
                this.imageView.Alpha = 1f;
                return;
            }

            ArticleImage article = Database.GetArticleImage(this.articleId);

            if (article == null)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_black_24dp);
                this.imageView.Alpha = 0.5f;

                return;
            }

            if (article.ImageLarge == null)
            {
                this.imageView.SetImageResource(Resource.Drawable.ic_photo_camera_black_24dp);
                this.imageView.Alpha = 0.5f;

                return;
            }

            string message;

            try
            {
                Bitmap largeBitmap = BitmapFactory.DecodeByteArray(article.ImageLarge, 0, article.ImageLarge.Length);

                this.imageView.SetImageBitmap(largeBitmap);

                message = string.Format("Bild (BxH): {0:n0} x {1:n0} (Größe: {2:n0}, Komprimiert: {3:n0})\r\n",
                                        largeBitmap.Width,
                                        largeBitmap.Height,
                                        Tools.ToFuzzyByteString(largeBitmap.ByteCount),
                                        Tools.ToFuzzyByteString(article.ImageLarge.Length));


                Bitmap smallBitmap = BitmapFactory.DecodeByteArray(article.ImageSmall, 0, article.ImageSmall.Length);

                message += string.Format("Thn. (BxH): {0:n0} X {1:n0} (Größe: {2:n0}, Komprimiert: {3:n0})",
                                         smallBitmap.Width,
                                         smallBitmap.Height,
                                         Tools.ToFuzzyByteString(smallBitmap.ByteCount),
                                         Tools.ToFuzzyByteString(article.ImageSmall.Length));

                largeBitmap = null;
                smallBitmap = null;
            }
            catch (Exception e)
            {
                TRACE(e);

                message = e.Message;
                this.imageView.SetImageResource(Resource.Drawable.baseline_error_outline_black_24);
                this.imageView.Alpha = 1f;
            }

            this.imageInfo.Text = message;
            article             = null;
        }