First, the source image is displayed in the ImageView (regardless of the image size, if the image is large, the proportion of the ImageVIew is reduced), because the image is processed by the user, of course, the smaller the image, the faster the processing, the better, so the project decided to use a copy of the image display for processing rather than the source image (because the source image may be large ).
Problem:
In order to steal some laziness, I am from ImageView. the copy obtained by the getDrawingCache method, because this copy is the real display size copy (imageView. getDrawable, this method gets the image of the source image size), my code is as follows:
View source
1 imageView. setDrawingCacheEnabled (Boolean. TRUE );
2 Bitmap tempBitmap = Bitmap. createBitmap (imageView. getDrawingCache ());
3 imageView. setDrawingCacheEnabled (Boolean. FALSE); // clear drawing cache
This code is okay when I run it on the simulator. tempBitmap has a value and is not null;
When I tested it on a real machine, the problem occurred. The tempBitmap is null; The imageView. getDrawingCache () method didn't get the cache at all.
I checked some other information on the Internet and tried to solve the problem. I hope someone else can give me some advice.
Development Environment: android 2.3.3 and android 2.3.5
Is it because of this version?
「 Here, I found some information abroad, which may be useful. I did not solve this problem, but many others did. 」
Http://www.bkjia.com/kf/201203/123437.html
From tonyley3