1
我嘗試從res/raw文件夾(這是一個png資源)解碼位圖(1920x1920)。我需要全尺寸位圖。我想使用BimtapFactory.decodeFileDescriptor而不是BitmapFactory.decodeFile || decodeResource,因爲比其他人處理OOM的可靠性更高: 雖然我嘗試使用此代碼,但位圖爲NULL!但該文件不爲空。我一直在努力玩。 幫助請!爲什麼res/raw文件夾中的位圖是空的?
Context mCtx=MainActivity.this;
Bitmap bm = null;
//id is the resId in res/raw
AssetFileDescriptor file =mCtx.getResources().openRawResourceFd(R.raw.skin_default_0);
bm = BitmapFactory.decodeFileDescriptor(file.getFileDescriptor(), null,
options);
據說(http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-位圖對象),decodeFileDescriptor調用與decodeStream/decodeFile不同的本地方法。我只是想將方塊(1920 * 1920)的圖像剪成1920 * 1080而沒有OOM。任何想法? – WZY