Exemple #1
0
        internal void UpdatePicture(string imgData, List <Dictionary <string, object> > coordIndexList)
        {
            var picture = BinaryToBitmap(imgData);

            if (picture != null)
            {
                image.SetImageBitmap(picture);
            }
            if (coordIndexList == null && coordIndexList.Count == 0)
            {
                return;
            }
            for (int i = 0; i < coordIndexList.Count; i++)
            {
                var x       = Convert.ToInt32(coordIndexList[i]["X"]);
                var y       = Convert.ToInt32(coordIndexList[i]["Y"]);
                var control = new Button(zoomLayout.Context);
                var param   = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                param.SetMargins(x, y, 0, 0);
                param.Width              = DpToPx(30, this.Context);
                param.Height             = DpToPx(30, this.Context);
                control.LayoutParameters = param;
                control.SetBackgroundColor(Color.Black);
                control.Text = coordIndexList[i]["Index"].ToString();
                control.SetTextColor(Color.White);
                zoomLayout.AddView(control);
            }
        }
 public virtual Com.Zhy.Adapter.Abslistview.ViewHolder SetImageBitmap(int viewId,
                                                                      Android.Graphics.Bitmap bitmap)
 {
     Android.Widget.ImageView view = GetView <ImageView>(viewId);
     view.SetImageBitmap(bitmap);
     return(this);
 }
Exemple #3
0
        async protected override void OnElementChanged(ElementChangedEventArgs <ImageControl> e)
        {
            base.OnElementChanged(e);

            m_control = e.NewElement;

            if (e.OldElement == null)
            {
                var nativeControl = new Android.Widget.FrameLayout(Context);
                nativeControl.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                nativeControl.SetBackgroundColor(m_control.BackgroundColor.ToAndroid());


                m_iconImageView = new Android.Widget.ImageView(Context);
                m_iconImageView.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                nativeControl.AddView(m_iconImageView);

                m_iconBitmap = await GetBitmapAsync(m_control.ImageUrl);

                if (m_iconBitmap != null)
                {
                    m_iconImageView.SetImageBitmap(m_iconBitmap);
                }

                SetNativeControl(nativeControl);
            }
            else
            {
                if (m_control.ImageUrl != e.OldElement.ImageUrl)
                {
                    m_iconBitmap = await GetBitmapAsync(m_control.ImageUrl);

                    if (m_iconBitmap != null)
                    {
                        m_iconImageView.SetImageBitmap(m_iconBitmap);
                    }
                }
            }
        }
Exemple #4
0
            /// <summary>
            /// Modifies the view before adding it to the gridview.
            /// </summary>
            protected override void InvokeCallback(string url, Android.Widget.ImageView iv, Android.Graphics.Bitmap bitmap, AjaxStatus status)
            {
                //imageViewOriginial = iv;
                iv.LayoutParameters = new RelativeLayout.LayoutParams(WindowManagerLayoutParams.MatchParent, _width);
                iv.SetScaleType(Android.Widget.ImageView.ScaleType.FitXy);
                //iv.SetPadding (2, 2, 2, 2);

                //Matrix used to crop image
                Matrix matrix = new Matrix();

                matrix.PostScale(0.5f, 0.5f);

                int size = _bm.Width;

                if (size >= 40)
                {
                    size = 40;
                }

                iv.SetImageBitmap(global::Android.Graphics.Bitmap.CreateBitmap(_bm, 0, 0, size, size, matrix, true));
                iv = null;
                _bm.Recycle();
            }