Android编程之图片相关代码集锦

2019-12-10 19:53:55王振洲
  • } catch (FileNotFoundException e) {   f.delete();  
  • e.printStackTrace();   } catch (IOException e) {  
  • e.printStackTrace();   f.delete();  
  • }   }  
  • 10.从SDCard中获取图片:

     

     
    1. /**   * @param imagePath 图片在SDCard中保存的路径  
    2. * @return 返回保存的bitmap对象   */ 
    3. public static Bitmap getImageFromLocal(String imagePath) {   File file = new File(imagePath);  
    4. if (file.exists()) {   Bitmap bitmap = BitmapFactory.decodeFile(imagePath);  
    5. file.setLastModified(System.currentTimeMillis());   return bitmap;  
    6. }   return null;