Android中怎样由图片的id号R.drawable.XX得到图片文件XX的绝对路径, 因为我想调用函数
Bitmap resizedBitmap=BitmapFactory.decodeFile(filepaths, options);其中的filepaths就是我要的drawable目录下图片文件的绝对路径.

解决方案 »

  1.   

    BitmapFactory.decodeFile这个有其他的重载,可以传resId进去的,你仔细看看。
      

  2.   

    BitmapFactory.decodeResource(Resources res, int id)  
      

  3.   

    因为我要对drawable目录下图片进行缩放,BitmapFactory.decodeFile的其他重载及BitmapFactory.decodeResource(Resources res, int id)都用不上,唯独要用BitmapFactory.decodeFile(filepaths, options)。
      

  4.   

    BitmapFactory.decodeResource(Resources res, int id, BitmapFactory.Options opts)  
      

  5.   

    建议你放在assert文件夹下面,然后操作assert
      

  6.   

    请问一下怎样在普通类中(没有继承Activity的类)对drawable中的图片进行压缩呢!非常感谢
      

  7.   


    Bitmap.createBitmap(Bitmap source, int x, int y,int width, int height, Matrix m, boolean filter)方法可以通过对源图像进行缩放操作得到一个新的被缩放后的图像。具体缩放的信息有Matrix指定的。
    如:
    Bitmap sourceBitmap = aBitmap;
    Matrix m = new Matrix();
    m.postScale(0.5f,0.5f);//缩小为原来的一半大小
    Bitmap newBitmap = Bitmap.createBitmap(sourceBitmap,0,0,sourceBitmap.getWidth(),sourceBitmap.getHeight(),m,true);
    这样就可以生成newBitmap了。