Пример #1
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;
        }
Пример #2
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);
            }
        }