Skip to content

Instantly share code, notes, and snippets.

@amrishodiq
Created September 23, 2011 06:50
Show Gist options
  • Save amrishodiq/1236867 to your computer and use it in GitHub Desktop.
Save amrishodiq/1236867 to your computer and use it in GitHub Desktop.
Blackberry - Use this snippet as an example of how to capture image using native camera in Blackberry
/**
* To use this example, you need to grap my repository on
* https://github.com/amrishodiq/Blackberry-Development-Tutorial/tree/master/TakingPicture/src/com/durianberry/takingpicture
*/
public final class TakingPictureScreen extends MainScreen implements
PictureTakerListener, FieldChangeListener {
private ButtonField button;
private BitmapField photoField;
public TakingPictureScreen() {
setTitle("Taking Picture");
button = new ButtonField("Take Picture", ButtonField.CONSUME_CLICK);
button.setChangeListener(this);
add(button);
photoField = new BitmapField();
add(photoField);
}
public void fieldChanged(Field field, int context) {
if (field == button) {
PictureTaker.get().setListener(this);
PictureTaker.get().takePicture();
}
}
public void onPictureCaptured(EncodedImage image) {
photoField.setImage(ImageTools.scaleImageToWidth(image, Display.getWidth()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment