Esempio n. 1
0
        private Bitmap GetPokemonIcon(int id)
        {
            if (iconSetUri == null || GoOnTapApplication.Config.IconSetUri == null || iconSetUri.ToString() != GoOnTapApplication.Config.IconSetUri.ToString())
            {
                iconSetBitmapRegionDecoder?.Recycle();
                iconSetStream?.Dispose();

                try
                {
                    byte[] iconSetBytes = GoOnTapApplication.Config.IconSetBytes;

                    if (iconSetBytes != null)
                    {
                        iconSetStream = new MemoryStream(iconSetBytes);
                    }
                    else
                    {
                        iconSetStream = Context.ContentResolver.OpenInputStream(GoOnTapApplication.Config.IconSetUri);
                    }
                }
                catch (Exception e)
                {
                    GoOnTapApplication.Config.IconSetUri   = Config.DefaultIconSets.Values.First();
                    GoOnTapApplication.Config.IconSetBytes = null;

                    iconSetStream = Context.ContentResolver.OpenInputStream(GoOnTapApplication.Config.IconSetUri);
                }

                try
                {
                    iconSetBitmapRegionDecoder = BitmapRegionDecoder.NewInstance(iconSetStream, false);
                }
                catch
                {
                    return(null);
                }

                iconSetUri = GoOnTapApplication.Config.IconSetUri;
            }

            if (iconSetBitmapRegionDecoder == null)
            {
                return(null);
            }

            int x      = (id - 1) % 10;
            int y      = (id - 1) / 10;
            int width  = iconSetBitmapRegionDecoder.Width / 10;
            int height = width;

            try
            {
                return(iconSetBitmapRegionDecoder.DecodeRegion(new Rect(width * x, height * y, width * x + width, height * y + height), new BitmapFactory.Options()));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 2
0
        private Bitmap CropAdjustPreview(System.String filePath)
        {
            BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder.NewInstance(filePath, false);

            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InJustDecodeBounds = true;
            BitmapFactory.DecodeFile(filePath, options);
            // setting up a cropping rect to grab only the top character info banner of the screenshot
            _width  = options.OutWidth / 4;
            _height = options.OutHeight / 2;
            Rect cropRect = new Rect(0, 0, _width, _height);

            // Decode bitmap with cropping rect set
            options.InJustDecodeBounds = false;
            return(bitmapRegionDecoder.DecodeRegion(cropRect, options));
        }
Esempio n. 3
0
        private Bitmap CropToCharacterStatus(String filePath, int upperBound, int lowerBound)
        {
            BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder.NewInstance(filePath, false);

            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InJustDecodeBounds = true;
            BitmapFactory.DecodeFile(filePath, options);
            // setting up a cropping rect to grab only the top character info banner of the screenshot
            int  width    = options.OutWidth;
            int  height   = lowerBound + 1;
            Rect cropRect = new Rect(0, upperBound, width, height);

            // Decode bitmap with cropping rect set
            options.InJustDecodeBounds = false;
            return(bitmapRegionDecoder.DecodeRegion(cropRect, options));
        }