コード例 #1
0
ファイル: StaticImage.cs プロジェクト: harrisse/Lotus
        public StaticImage(Resources resources, int id)
        {
            mBitmap = BitmapDrawable.Create(resources, id);
            ShouldBeEjected = false;

            DrawThread.StaticLayer.Add(this);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }
コード例 #5
0
ファイル: ImageFragment.cs プロジェクト: vijeshrpillai/BNR
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 //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 { }
 }
コード例 #8
0
 public void SetPlaceholder(BitmapDrawable drawable, int animationDuration)
 {
     if (!animating)
     {
         normalized      = 0f;
         alpha           = 255;
         fadeDuration    = animationDuration;
         startTimeMillis = SystemClock.UptimeMillis();
         placeholder     = drawable;
         animating       = true;
     }
 }
コード例 #9
0
ファイル: PictureUtils.cs プロジェクト: vijeshrpillai/BNR
        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);
        }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
        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);
        }
コード例 #12
0
        /// <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();
            }
        }
コード例 #13
0
ファイル: MovableImage.cs プロジェクト: harrisse/Lotus
 public MovableImage(BitmapDrawable drawable)
     : base()
 {
     mDrawable = drawable;
     DrawThread.DynamicLayer.Add(this);
 }
コード例 #14
0
ファイル: Bullet.cs プロジェクト: harrisse/Lotus
 public Bullet(BitmapDrawable drawable, MaxPointVector velocity)
     : base(drawable)
 {
     Velocity = velocity;
 }