本文整理汇总了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);
}
示例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();
}
}
}
示例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));
};
}
示例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;
}
示例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;
}
示例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");
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
});
}
示例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);
}
示例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 ();
}
示例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));
}
});
};
}
示例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 );
}
}
示例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;
}