public class AndroidBitmap extends Activity {
private final String imageInSD = "/sdcard/er.PNG";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
}
}
或
final Bitmap bm = BitmapFactory.decodeStream(..some image..);
// The openfileOutput() method creates a file on the phone/internal storage in the context of your application
final FileOutputStream fos = openFileOutput("my_new_image.jpg", Context.MODE_PRIVATE); // Use the compress method on the BitMap object to write image to the OutputStream
bm.compress(CompressFormat.JPEG, 90, fos);
希望工程......
謝謝,但我沒有在SD卡中保存圖像,使用** MODE_PRIVATE ** .any的想法保存圖像到內部存儲器中以獲取內部存儲器的路徑名。 – 2012-01-05 06:05:21
final Bitmap bm = BitmapFactory.decodeStream(..some image ..); // openfileOutput()方法在應用程序上下文中在手機/內部存儲上創建一個文件 final FileOutputStream fos = openFileOutput(「my_new_image.jpg」,Context.MODE_PRIVATE); //使用BitMap對象上的compress方法將圖像寫入OutputStream中bm.compress(CompressFormat.JPEG,90,fos); – 2012-01-05 06:09:18
Thanx @Nikhilreddy Gujjula – 2012-01-05 06:11:19