public StaticImage(Resources resources, int id) { mBitmap = BitmapDrawable.Create(resources, id); ShouldBeEjected = false; DrawThread.StaticLayer.Add(this); }
public static async Task <Stream> AsJpegStreamAsync(this BitmapDrawable drawable, int quality = 90) { var stream = new MemoryStream(); await drawable.Bitmap.CompressAsync(Android.Graphics.Bitmap.CompressFormat.Jpeg, quality, stream); if (stream.Position != 0) { stream.Position = 0; } return(stream); }
public static async Task <Stream> AsPngStreamAsync(this BitmapDrawable drawable) { var stream = new MemoryStream(); await drawable.Bitmap.CompressAsync(Android.Graphics.Bitmap.CompressFormat.Png, 100, stream); if (stream.Position != 0) { stream.Position = 0; } return(stream); }
/// <summary> /// Resets the global variables and visbility of the mobile view /// </summary> void HandleHoverAnimationEnd(object sender, EventArgs e) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mHoverCell.SetVisible(false, false); mHoverCell = null; Enabled = true; Invalidate(); mobileView.Visibility = ViewStates.Visible; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mImageView = new ImageView(Activity); string path = Arguments.GetString(EXTRA_IMAGE_PATH); float rotation = Arguments.GetFloat(EXTRA_IMAGE_ROTATION); BitmapDrawable image = PictureUtils.GetScaledDrawable(Activity, path); mImageView.SetImageDrawable(image); mImageView.Rotation = rotation; return(mImageView); }
private BitmapDrawable GetDrawable(string imageEntryImage) { int resID = Resources.GetIdentifier(imageEntryImage, "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; var bitmapScaled = Bitmap.CreateScaledBitmap(bitmap, element.ImageWidth * 2, element.ImageHeight * 2, true); var bitmapDrawable = new BitmapDrawable(Resources, bitmapScaled); bitmapScaled.Dispose(); return(bitmapDrawable); }
//Intents to Camera protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { try { base.OnActivityResult(requestCode, resultCode, data); Bitmap bitmap = (Bitmap)data.Extras.Get("data"); ImageViewProfileImage.SetImageBitmap(bitmap); BitmapDrawable drawable = (BitmapDrawable)ImageViewProfileImage.Drawable; BitProfilePic = drawable.Bitmap; } catch { } }
public void SetPlaceholder(BitmapDrawable drawable, int animationDuration) { if (!animating) { normalized = 0f; alpha = 255; fadeDuration = animationDuration; startTimeMillis = SystemClock.UptimeMillis(); placeholder = drawable; animating = true; } }
public static void CleanImageView(ImageView imageView) { if (imageView == null || imageView.Drawable == null || imageView.Drawable.GetType() != typeof(BitmapDrawable)) { return; } // Clean up the view's image for the sake of memory BitmapDrawable b = (BitmapDrawable)imageView.Drawable; b.Bitmap.Recycle(); imageView.SetImageDrawable(null); }
private void OnEntryAdded(Uri key, BitmapDrawable value) { total_added++; Log.Debug(TAG, "OnEntryAdded(key = {0})", key); if (value is SelfDisposingBitmapDrawable) { var sdbd = (SelfDisposingBitmapDrawable)value; sdbd.SetIsCached(true); sdbd.InCacheKey = key; sdbd.Displayed += OnEntryDisplayed; UpdateByteUsage(sdbd.Bitmap); } }
public bool InitializeImageContainer(IImageContainer container, IApplicationContext context) { String imgPath = BackgroundImage(container); if (imgPath != null) { BitmapDrawable img = GetImage(context, imgPath); container.ImageWidth = img.Bitmap.Width; container.ImageHeight = img.Bitmap.Height; return(true); } return(false); }
/// <summary> /// Caches all animations. /// </summary> private void CacheAnimations() { try { foreach (AnimationType animation in Enum.GetValues(typeof(AnimationType))) { if (animation == AnimationType.None || animation == AnimationType.ShirtPullDown) { continue; } var animationDrawable = new AnimationDrawable(); using (var stream = new StreamReader(Assets.Open(string.Format("{0}.xml", animation)))) { var document = XDocument.Load(stream); var root = document.Root; var elements = root.Descendants(); foreach (var element in elements) { var drawable = ReadAttribute(element, "drawable"); var duration = ReadAttribute(element, "duration"); var bitmapStringId = drawable.Substring(drawable.IndexOf('/') + 1); var resID = Resources.GetIdentifier(bitmapStringId, "drawable", PackageName); BitmapFactory.Options options = new BitmapFactory.Options(); options.InJustDecodeBounds = false; options.InPreferredConfig = Bitmap.Config.Rgb565; options.InDither = true; options.InSampleSize = 2; options.InPurgeable = true; using (Bitmap bitmap = BitmapFactory.DecodeResource(Resources, resID, options)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap); animationDrawable.AddFrame(bitmapDrawable, int.Parse(duration)); } } // cache animation _animationsDrawable.Add(animation.ToString(), animationDrawable); } } } catch (Exception ex) { _statusTextView.Text = ex.ToString(); } }
public MovableImage(BitmapDrawable drawable) : base() { mDrawable = drawable; DrawThread.DynamicLayer.Add(this); }
public Bullet(BitmapDrawable drawable, MaxPointVector velocity) : base(drawable) { Velocity = velocity; }