0

I am new to the Titanium Android Mobile application development.

My problem is how do i load the last captured image of camera in an image view.

I have a bitton called as click in one window and I have to display that image in second window.

How will I achieve this , remebr no code is needed only using the Titanium android.

Thanks

Sigar Dave
  • 2,598
  • 1
  • 20
  • 42
  • problem mean error , and you should post error here. even you haven't post any code. What you have tried ? – Chintan Khetiya Dec 27 '13 at 12:46
  • yes without code as i am just developing the screens .. – Sigar Dave Dec 27 '13 at 13:29
  • there is no error as this is the functionality i will require to implement in the coming time.. i have two scrrens one captures the image and other will show the capture image immediately – Sigar Dave Dec 27 '13 at 13:30

3 Answers3

1

Try this code...

Ti.Media.showCamera({
    success : function(event) {

       if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
          // Here you can do whatever you want with the image captured from the camera
          var imgView = Ti.UI.CreateImageView({
             image: event.media,
             width: Ti.UI.SIZE, height: Ti.UI.SIZE
          });
          Ti.UI.currentWindow.add(imgView); // It will be added to the centre of the window if you didn't specify top or left or ...
       } else {
        alert("got the wrong type back =" + event.mediaType);
       }        
    },
    cancel : function() {
       alert("You have cancelled !");
    },
    error : function(error) {
       alert("error");
    },
       saveToPhotoGallery : true,
       allowEditing : true,
       mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});
Zabady
  • 301
  • 1
  • 3
  • 14
  • thanks, but i am able to add that window to the current windiw but that is not the thing i want to achieve. i wnat to add that image in the imageviewwebpart which is located on another winsow. – Sigar Dave Dec 30 '13 at 06:43
0

You will receive the captured image data via a method of the Callback interface. Callback interface is used to supply image data from a photo capture.

Camera.PictureCallback

onPictureTaken(byte[] data, Camera camera)
{
     ......
     Your code
     ......
}

You can do whatever you want to do with image data here. Means you can set the image to imageview here. You will receive data in bytes. Simply convert it to drawable/bitmap and set that drawable/bitmap to the imageview. Thats it!

For converting bytes to bitmap you can use this link : How to convert byte array to Bitmap

Community
  • 1
  • 1
0

Thanks for all the response ... I have solved this my own.

var image = event.media;

then capture the native path for the image using nativePath

image.nativePath

and then store this path to the application property and reuse this property using Application getString function.

Sigar Dave
  • 2,598
  • 1
  • 20
  • 42