public boolean createReflectedImages() {
//倒影图和原图之间的距离
final int reflectionGap = 4;
int index = 0;
for (int imageId : mImageIds) {
//返回原图解码之后的bitmap对象
System.out.println(imageId+"++++");
Bitmap originalImage = BitmapFactory.decodeResource(mContext.getResources(), imageId);
System.out.println(originalImage);
int width = originalImage.getWidth();
int height = originalImage.getHeight();
这段代码运行后,08-28 09:16:11.850: INFO/System.out(358): 2130837505++++
08-28 09:16:11.859: INFO/System.out(358): null
由于代码多我只放了一点,为什么在originalImage对象前imageId都能拿到值,但是到了运行 Bitmap originalImage = BitmapFactory.decodeResource(mContext.getResources(), imageId)
后originaImage对象是null呢?
------解决方案--------------------------------------------------------
originalImage 没有new吧,Bitmap originalImage = new Bitmap(imageId )
这样就不会出现originaImage对象是null了