当前位置: 首页>>代码示例>>C#>>正文


C# ImageView.SetImageBitmap方法代码示例

本文整理汇总了C#中ImageView.SetImageBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# ImageView.SetImageBitmap方法的具体用法?C# ImageView.SetImageBitmap怎么用?C# ImageView.SetImageBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageView的用法示例。


在下文中一共展示了ImageView.SetImageBitmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetImageFromUrlAsync

		public static async Task SetImageFromUrlAsync (ImageView imageView, string url)
		{
			var bmp = FromUrl(url);
			if (bmp.IsCompleted)
				imageView.SetImageBitmap (bmp.Result);
			else
				imageView.SetImageBitmap (await bmp);
		}
开发者ID:ConundrumSystems,项目名称:PowerpointAppStyle,代码行数:8,代码来源:Images.cs

示例2: SetIcon

        public void SetIcon(Item item, ImageView view, Activity activity)
        {
            var path = GetIconPath(item);
            if (File.Exists(path))
            {
                var icon = BitmapFactory.DecodeFile(path);

                if (view != null & activity != null)
                {
                    activity.RunOnUiThread(
                        () => view.SetImageBitmap(BitmapFactory.DecodeFile(path)));
                }
            }
            _iconsToLoad.Enqueue
                (
                    new IconToLoad
                    {
                        Item = item,
                        ImageView = view,
                        Activity = activity
                    }
                );

            lock (_backgroundWorker)
            {
                if (!_backgroundWorker.IsBusy)
                {
                    _backgroundWorker.RunWorkerAsync();
                }
            }
        }
开发者ID:vecode,项目名称:GW2Trader,代码行数:31,代码来源:IconStore.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _nickViewModel = ServiceContainer.Resolve<NickViewModel>();

            SetContentView(Resource.Layout.ResultLayout);

            Typeface fancy = Typeface.CreateFromAsset(Assets, "Fonts/Snell Roundhand Script.ttf");
            _greetingsText = FindViewById<TextView>(Resource.Id.greetingsText);
            _greetingsText.Text = string.Empty;
            _greetingsText.Typeface = fancy;

            _resultText = FindViewById<TextView>(Resource.Id.resultText);
            _resultText.Text = "Traveling...";

            _greetingsImage = FindViewById<ImageView>(Resource.Id.greetingsImage);
            _nicImage = FindViewById<ImageView>(Resource.Id.nickImage);
            _itemImage = FindViewById<ImageView>(Resource.Id.itemImage);

            _greetingsImage.SetImageBitmap(null);
            _nicImage.SetImageBitmap(null);
            _itemImage.SetImageBitmap(null);

            var adventureButton = FindViewById<Button>(Resource.Id.adventureButton);
            adventureButton.Click += (sender, e) =>
                {
                    StartActivity(typeof(MainActivity));
                };
        }
开发者ID:t12my,项目名称:pick-a-nick,代码行数:30,代码来源:ResultActivity.cs

示例4: GetView

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ImageView imageView = new ImageView(mContext);
            imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            imageView.LayoutParameters = (new GridView.LayoutParams(250, 250));

            if (Categories[position].Picture != null)
            {
                var webClient = new WebClient();
                webClient.DownloadDataCompleted += (s, e) =>
                {
                    try
                    {
                        var bytes = e.Result; // get the downloaded data
                        
                        imageView.SetImageBitmap(ImageHandler.BytesToImage(bytes));  // convert the data to an actual image
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Something went wrong loading image for cell..." + ex.Message);
                    }

                };
                webClient.DownloadDataAsync(new Uri(Categories[position].Picture));
            }

            return imageView;
        }
开发者ID:dsb92,项目名称:patientcare,代码行数:28,代码来源:CategoryAdapter.cs

示例5: OnCreateView

        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            //			Console.WriteLine("[{0}] OnCreateView Called: {1}", TAG, DateTime.Now.ToLongTimeString());
            View v = inflater.Inflate(Resource.Layout.fragment_photo, container, false);

            mImageView = v.FindViewById<ImageView>(Resource.Id.photoView);

            photoUrl = Activity.Intent.GetStringExtra(PhotoGalleryFragment.PHOTO_URL_EXTRA);

            photoUrl = photoUrl.Substring(0, photoUrl.Length-6) + ".jpg";
            photoFilename = new FlickrFetchr().GetFilenameFromUrl(photoUrl);

            ProgressDialog pg = new ProgressDialog(Activity);
            pg.SetMessage(Resources.GetString(Resource.String.loading_photo_message));
            pg.SetTitle(Resources.GetString(Resource.String.loading_photo_title));
            pg.SetCancelable(false);
            pg.Show();

            Task.Run(async () => {
                Bitmap image = await new FlickrFetchr().GetImageBitmapAsync(photoUrl, 0, new CancellationTokenSource().Token, photoFilename).ConfigureAwait(false);
                Activity.RunOnUiThread(() => {
                    mImageView.SetImageBitmap(image);
                    //Console.WriteLine("[{0}] File created: {1}", TAG, photoUrl);
                    pg.Dismiss();
                });
            });

            return v;
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:29,代码来源:PhotoFragment.cs

示例6: SetBackground

        protected void SetBackground(ImageView topImg, ImageView bottomImg, TextView caption1
            , TextView caption2, ImageView logoImg)
        {
            switch (Settings.CurrentSolutionType)
            {
                case SolutionType.SuperAgent:
                    using (Bitmap topImgBitmap = DecodeBitmap(Resource.Drawable.SuperAgentTop))
                        topImg.SetImageBitmap(topImgBitmap);
                    using (Bitmap bottomImgBitmap = DecodeBitmap(Resource.Drawable.SuperAgentBottom))
                        bottomImg.SetImageBitmap(bottomImgBitmap);
                    caption1.Text = D.BIT_CATCH1;
                    caption2.Text = D.BIT_CATCH2;
                    using (Bitmap logoImgBitmap = DecodeBitmap(Resource.Drawable.SuperAgentLogo))
                        logoImg.SetImageBitmap(logoImgBitmap);
                    break;

                case SolutionType.SuperService:
                    using (Bitmap topImgBitmap = DecodeBitmap(Resource.Drawable.SuperServiceTop))
                        topImg.SetImageBitmap(topImgBitmap);
                    using (Bitmap bottomImgBitmap = DecodeBitmap(Resource.Drawable.SuperServiceBottom))
                        bottomImg.SetImageBitmap(bottomImgBitmap);
                    caption1.Text = D.SUPER_SERVICE1;
                    caption2.Text = D.SUPER_SERVICE2;
                    using (Bitmap logoImgBitmap = DecodeBitmap(Resource.Drawable.SuperServiceLogo))
                        logoImg.SetImageBitmap(logoImgBitmap);
                    break;

                case SolutionType.LandSuperService:
                    using (Bitmap topImgBitmap = DecodeBitmap(Resource.Drawable.SuperServiceTop))
                        topImg.SetImageBitmap(topImgBitmap);
                    using (Bitmap bottomImgBitmap = DecodeBitmap(Resource.Drawable.SuperServiceBottom))
                        bottomImg.SetImageBitmap(bottomImgBitmap);
                    using (Bitmap logoImgBitmap = DecodeBitmap(Resource.Drawable.LandSuperServiceLogo))
                        logoImg.SetImageBitmap(logoImgBitmap);
                    ((LinearLayout.LayoutParams)logoImg.LayoutParameters).Weight = 1;
                    using (var specialfor = Activity.FindViewById<ImageView>(Resource.Id.specialfor))
                    using (Bitmap specialforBitmap = DecodeBitmap(Resource.Drawable.Specialfor))
                        specialfor.SetImageBitmap(specialforBitmap);
                    using (var clientLogo = Activity.FindViewById<ImageView>(Resource.Id.clientLogo))
                    using (Bitmap clientLogoBitmap = DecodeBitmap(Resource.Drawable.LandLogo))
                        clientLogo.SetImageBitmap(clientLogoBitmap);
                    break;

                default:
                    throw new NotImplementedException("Current solution type is not supported");
            }
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:47,代码来源:InitialScreen.cs

示例7: SetSource

 private async void SetSource(ImageView img, string src) {
     var bm = await this.Source.GetBitmap(src);
     if (bm != null) {
         img.SetImageBitmap(bm);
         img.SetScaleType(ImageView.ScaleType.FitXy);
         bm.Dispose();
     }
 }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:8,代码来源:FlipViewAdapter.cs

示例8: Scale

 ImageView Scale(ImageView source)
 {
     var drawable = (BitmapDrawable)source.Drawable;
     var bitmap = drawable.Bitmap;
     var bMapScaled = Bitmap.CreateScaledBitmap(bitmap, dimx, dimy, true);
     source.SetImageBitmap(bMapScaled);
     return source;
 }
开发者ID:rkamphorst,项目名称:Android.Dialog,代码行数:8,代码来源:ImageElement.cs

示例9: UpdateImage

		static void UpdateImage (ImageView image, ScavengerHuntCellViewModel viewModel) {
			if (viewModel.CapturedImage != null) {
				using (var bitmap = BitmapFactory.DecodeByteArray (viewModel.CapturedImage, 0, viewModel.CapturedImage.Length)) {
					image.SetImageBitmap (bitmap);
				}
			} else {
				image.SetImageResource (Resource.Drawable.add_pic);
			}
		}
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:9,代码来源:ScavengerHuntCellRenderer.cs

示例10: UpdateUserProfile

 public static void UpdateUserProfile(this ServerEventConnect connectMsg,TextView txtUser, ImageView imgProfile)
 {
     Application.SynchronizationContext.Post(_ => { txtUser.Text = connectMsg.DisplayName; }, null);
     connectMsg.ProfileUrl.GetImageBitmap()
         .ContinueWith(
             bitmap =>
             {
                 Application.SynchronizationContext.Post(_ => { imgProfile.SetImageBitmap(bitmap.Result); }, null);
             });
 }
开发者ID:ServiceStackApps,项目名称:AndroidXamarinChat,代码行数:10,代码来源:Extensions.cs

示例11: iniUserList

		private void iniUserList(ImageView imguserlist,String path){		

			int tam = Configuration.getWidth (85);

			Bitmap newbm = Configuration.getRoundedShape(Bitmap.CreateScaledBitmap(getBitmapFromAsset (path), Configuration.getWidth(100), Configuration.getWidth(100), true)
				,tam,tam);

			imguserlist.SetImageBitmap (newbm);

		}
开发者ID:aocsa,项目名称:eduticnow.droid,代码行数:10,代码来源:ItemUser.cs

示例12: ImageNodeView

        public ImageNodeView(Context context, ImageNode image)
            : base(context, image)
        {
            this.image = image;
            this.view = new ImageView (context);

            var bitmap = Resources.GetBitmap(image.File);
            view.SetImageBitmap (bitmap);
            AddView (view);
            bitmap.Dispose ();
        }
开发者ID:Clancey,项目名称:Canvas,代码行数:11,代码来源:ImageNodeView.cs

示例13: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.buttonLocation);
            LabelLocation = FindViewById<TextView>(Resource.Id.locationLabel);
            image = FindViewById<ImageView>(Resource.Id.imagePhoto);

            button.Click += delegate {

                var locator = new Geolocator(this) { DesiredAccuracy = 50 };
                locator.GetPositionAsync(timeout: 10000).ContinueWith(t =>
                {
                    var text = String.Format("Location : Lat: {0}, Long: {0}", t.Result.Latitude, t.Result.Longitude);
                    this.RunOnUiThread(() => LabelLocation.Text = text);
                });
            };

            Button getimge = FindViewById<Button>(Resource.Id.buttonCamera);
            getimge.Click += delegate
            {
                var camera = new MediaPicker(this);

                if (!camera.IsCameraAvailable)
                {
                    Console.WriteLine("Camera unavailable!");
                    return;
                }

                var opts = new StoreCameraMediaOptions
                {
                    Name = "test.jpg",
                    Directory = "MiniHackDemo"
                };

                camera.TakePhotoAsync(opts).ContinueWith(t =>
                {
                    if (t.IsCanceled)
                        return;

                    using (var bmp = Android.Graphics.BitmapFactory.DecodeFile(t.Result.Path))
                    {
                        this.RunOnUiThread(() => image.SetImageBitmap(bmp));
                    }
                });
                
            };
        }
开发者ID:nagyist,项目名称:mini-hacks,代码行数:53,代码来源:Activity1.cs

示例14: SetBitmap

 private void SetBitmap( string url, int width, int height, ImageView imageView, CancellationToken token )
 {
     Bitmap bitmap = ImageDownloader.DownloadImage( url, width, height );
     if( !token.IsCancellationRequested )
         (this.m_context as Activity).RunOnUiThread( () => imageView.SetImageBitmap( bitmap ) );
     lock( m_lockObject )
     {
         ImageViewTask task = m_bitMapTasks.Find( t => t.View == imageView );
         if( task != null )
             m_bitMapTasks.Remove( task );
     }
 }
开发者ID:rohithc,项目名称:TestImageDownloader,代码行数:12,代码来源:ImageDownloader.cs

示例15: OnCreateView

		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			var rootView = inflater.Inflate(layoutId, null);

			using (var bitmap = BitmapFactory.DecodeResource (Resources, bitmapId)) {
				v = (ImageView)rootView.FindViewById (Resource.Id.image);
				v.SetImageBitmap (bitmap);
			}
		
	
			return rootView;
		}
开发者ID:billy-lokal,项目名称:Dateifi_Old,代码行数:12,代码来源:IntroActivity.cs


注:本文中的ImageView.SetImageBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。