我正在开发一个应用程序,它可以在服务器调用时获取图像并将该图像发送到服 这是CameraSurfaceView我定义的类中的一些代码.
private SurfaceHolder holder;
private Camera camera;
private Bitmap osb;
public void takeImage(){
Camera camera = this.getCamera();
CameraSurfaceView.HandlePictureStorage c = this.new HandlePictureStorage();
camera.takePicture(null, null, c);
}
public byte[] getImage(String type) {
if (osb==null) {
System.err.println("Camera.getImage: osb NULL");
return null;
}
CompressFormat format = CompressFormat.JPEG;
if (type.equals("PNG")) {
format = CompressFormat.PNG;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
System.err.println("Camera.getImage: decoded");
osb.compress(format, 100, out);
System.err.println("Camera.getImage: compressed");
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
} finally …Run Code Online (Sandbox Code Playgroud)