Code where I set the size:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int
h) {
Camera.Parameters parameters = camera.getParameters();
List<Size> sizes = parameters.getSupportedPictureSizes();
int width = 0, height = 0;
if(sizes == null) {
width = 480; height = 320;
} else {
for(int i = 0; i < sizes.size(); i++) {
Size s = sizes.get(i);
if(width == 0 || (s.width < width && s.width >= 1600)) {
width = s.width;
height = s.height;
}
}
parameters.setPictureSize(width, height);
camera.setParameters(parameters);
}
//AppGUI.ShowInfo((Activity)this.getContext(), str, "Sizes");
camera.startPreview();
}
Code to take the picture:
buttonClick.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
taken = false;
buttonClick.setEnabled(false);
preview.camera.setPreviewCallback(null);
preview.camera.setOneShotPreviewCallback(null);
preview.camera.autoFocus(myAutoFocusCallback);
}
});
AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback(){
public void onAutoFocus(boolean arg0, Camera arg1) {
preview.camera.takePicture(shutterCallback, rawCallback,
jpegCallback);
}};
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
FormCamera.this.taken = true;
FileOutputStream outStream = null;
try {
if(which == FormRDC.MENU_ATTACH2 || only) {
Intent cameraRes = new Intent();
cameraRes.setData(Uri.parse(fname));
FormCamera.this.setResult(0, cameraRes);
}
File f = new File(FormCamera.this.getFilesDir(), fname);
outStream = new FileOutputStream(f);
outStream.write(data);
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(which == FormRDC.MENU_ATTACH2 || only) {
FormCamera.this.finish();
} else {
try {
Thread.sleep(1500);
} catch(Exception e) {}
setup(FormRDC.MENU_ATTACH2);
preview.surfaceChanged(null, 0, 0, 0);
}
}
}
};
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en