我正尝试通过简单的活动使用Android相机捕捉图像。
单击并存储图像。但问题是,图像失真或旧图像的片段与当前点击的图像连接在一起。图像太暗了。这是代码: -
public class Cameras extends Activity {
public Camera camera;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
camera=Camera.open();
camera.lock();
Parameters parameters = camera.getParameters();
parameters.setJpegQuality(1);
parameters.setJpegThumbnailQuality(1);
parameters.setJpegThumbnailSize(0,0);
parameters.setSceneMode("night");
parameters.setFocusMode("fixed");
parameters.setPictureSize(640,480);
camera.setParameters(parameters);
camera.takePicture(null,null, jpegCallback);
}
PictureCallback jpegCallback = new PictureCallback() { // <8>
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
try {
// Write to SD Card
outStream = new FileOutputStream(String.format("/sdcard/%d.jpg",System.currentTimeMillis())); // <9>
outStream.write(data);
outStream.close();
camera.unlock();
camera.release();
Toast.makeText(Cameras.this,"Picture Taken",Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally
{
}
}
};
}
请帮忙解决这个问题...... 每次执行代码时,我都想要一个整洁干净的小尺寸图像。
谢谢......: - )
答案 0 :(得分:2)
parameters.setJpegQuality(1);
parameters.setJpegThumbnailQuality(1);
您要求的质量非常低。尝试使用更高的质量值(如70)