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