如何在sdcard上保存位图图像jpeg?

Rez*_*_Rg 2 android jpeg image bitmap save

我正在尝试编写应用程序以从图库中获取图像,然后在其上执行一些效果,并在显示图像后,我想将其保存为SdCard中的JPG.任何人都可以告诉我如何在SD卡上保存图像,我应该在哪里放保存代码?这是我想要保存的地方,点击button2后:

public void onClick(View arg0) {
                    Bitmap yourimage;
                    yourimage=toGrayscale(yourSelectedImage);
                    ImageButton effected=(ImageButton)findViewById(R.id.imageButton2);
                    int width = 150;
                    int height =150; 
                    Bitmap resizedbitmap=Bitmap.createScaledBitmap(yourimage, width, height, true);
                    effected.setImageBitmap(resizedbitmap);
}
Run Code Online (Sandbox Code Playgroud)

我的意思是在设置图像为resizedbitmap后,我想将其保存在SD卡中

WIl*_*JBD 7

这基本上就是这样

Bitmap bmp = createBitmap();
OutputStream stream = new FileOutputStream("/sdcard/test.jpg");
bmp.compress(CompressFormat.JPEG, 100, stream);
Run Code Online (Sandbox Code Playgroud)