public /* override */ virtual Bitmap OnLoadBitmap()
 {
     BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
     decodeOptions.InPreferredConfig = Config.Argb8888;
     //		decodeOptions.InScaled = false; // TODO Check how this behaves with drawable-""/nodpi/ldpi/mdpi/hdpi folders
     return BitmapFactory.DecodeResource(this.mContext.Resources, this.mDrawableResourceID, decodeOptions);
 }
 public /* override */ virtual Bitmap OnLoadBitmap()
 {
     BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
     decodeOptions.InPreferredConfig = Config.Argb8888;
     //		decodeOptions.InScaled = false; // TODO Check how this behaves with drawable-""/nodpi/ldpi/mdpi/hdpi folders
     return(BitmapFactory.DecodeResource(this.mContext.Resources, this.mDrawableResourceID, decodeOptions));
 }
Ejemplo n.º 3
0
        // ===========================================================
        // Constructors
        // ===========================================================

        public AssetTextureSource(Context pContext, String pAssetPath)
        {
            this.mContext   = pContext;
            this.mAssetPath = pAssetPath;

            BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
            decodeOptions.InJustDecodeBounds = true;

            //InputStream input = null;
            System.IO.Stream input = null;
            try
            {
                //input = pContext.getAssets().open(pAssetPath);
                input = pContext.Assets.Open(pAssetPath);
                BitmapFactory.DecodeStream(input, null, decodeOptions);
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + pAssetPath, e);
            }
            finally
            {
                StreamUtils.CloseStream(input);
            }

            this.mWidth  = decodeOptions.OutWidth;
            this.mHeight = decodeOptions.OutHeight;
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        public AssetTextureSource(Context pContext, String pAssetPath)
        {
            this.mContext = pContext;
            this.mAssetPath = pAssetPath;

            BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
            decodeOptions.InJustDecodeBounds = true;

            //InputStream input = null;
            System.IO.Stream input = null;
            try
            {
                //input = pContext.getAssets().open(pAssetPath);
                input = pContext.Assets.Open(pAssetPath);
                BitmapFactory.DecodeStream(input, null, decodeOptions);
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + pAssetPath, e);
            }
            finally
            {
                StreamUtils.CloseStream(input);
            }

            this.mWidth = decodeOptions.OutWidth;
            this.mHeight = decodeOptions.OutHeight;
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        public ResourceTextureSource(Context pContext, int pDrawableResourceID)
        {
            this.mContext            = pContext;
            this.mDrawableResourceID = pDrawableResourceID;

            BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
            decodeOptions.InJustDecodeBounds = true;
            //		decodeOptions.inScaled = false; // TODO Check how this behaves with drawable-""/nodpi/ldpi/mdpi/hdpi folders

            BitmapFactory.DecodeResource(pContext.Resources, pDrawableResourceID, decodeOptions);

            this.mWidth  = decodeOptions.OutWidth;
            this.mHeight = decodeOptions.OutHeight;
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        public ResourceTextureSource(Context pContext, int pDrawableResourceID)
        {
            this.mContext = pContext;
            this.mDrawableResourceID = pDrawableResourceID;

            BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
            decodeOptions.InJustDecodeBounds = true;
            //		decodeOptions.inScaled = false; // TODO Check how this behaves with drawable-""/nodpi/ldpi/mdpi/hdpi folders

            BitmapFactory.DecodeResource(pContext.Resources, pDrawableResourceID, decodeOptions);

            this.mWidth = decodeOptions.OutWidth;
            this.mHeight = decodeOptions.OutHeight;
        }
Ejemplo n.º 7
0
        Bitmap CreateBitmap(string path)
        {
            BitmapFactory.Options options = new BitmapFactory.Options
            {
                //options.InJustDecodeBounds = true; // 先获取原大小
                //return BitmapFactory.DecodeFile(path, options);
                InJustDecodeBounds = false // 获取新的大小
            };
            int sampleSize = (int)(options.OutHeight / (float)200);

            if (sampleSize <= 0)
            {
                sampleSize = 1;
            }
            options.InSampleSize = sampleSize;

            return(BitmapFactory.DecodeFile(path, options));
        }
Ejemplo n.º 8
0
        public /* override */ virtual Bitmap OnLoadBitmap()
        {
            System.IO.Stream input = null;
            //InputStream input = null;
            try
            {
                BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
                decodeOptions.InPreferredConfig = Config.Argb8888;

                //input = this.mContext.getAssets().open(this.mAssetPath);
                input = this.mContext.Assets.Open(this.mAssetPath);
                return(BitmapFactory.DecodeStream(input, null, decodeOptions));
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + this.mAssetPath, e);
                return(null);
            }
            finally
            {
                //StreamUtils.closeStream(input);
            }
        }
        public /* override */ virtual Bitmap OnLoadBitmap()
        {
            System.IO.Stream input = null;
            //InputStream input = null;
            try
            {
                BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
                decodeOptions.InPreferredConfig = Config.Argb8888;

                //input = this.mContext.getAssets().open(this.mAssetPath);
                input = this.mContext.Assets.Open(this.mAssetPath);
                return BitmapFactory.DecodeStream(input, null, decodeOptions);
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + this.mAssetPath, e);
                return null;
            }
            finally
            {
                //StreamUtils.closeStream(input);
            }
        }