I am writing an android app and I am offering the user the ability to load a picture from the library.
The picture is loaded but rotated 90 degrees. Sometimes it is rotated -90 degrees.
How can I load the picture "the same way" it shows when you view it by your libray?
So if it is rotated then sure load it rotated it. But if it is correct, then it should be loaded the same way
Thank you very much
Sorry guys I should've added my code, Here it is:
try {
Intent choosePictureIntent = new Intent(Intent.ACTION_PICK, Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(choosePictureIntent, REQUEST_CHOOSE_IMAGE);
} catch (Exception e) {
e.printStackTrace();
}
break;
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case REQUEST_CHOOSE_IMAGE:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
InputStream imageStream;
try {
imageStream = getContentResolver().openInputStream(selectedImage);
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream, null, options );
ivPictureChosen.setImageBitmap(yourSelectedImage); //ivPictureChosen is image view to display the picture
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(this, "Couldn't pick image", Toast.LENGTH_SHORT).show();
}
}
}
}
I'm attempting the code below. It examines the orientation of the image and then rotates it accordingly. The issue I have is running out of memory and have yet to find a solution to exceeding the VM buget. This should work on smaller images and when your app is not already using a lot of memory.
ExifInterface ei = new ExifInterface(filePath);
int orientation = ei.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotateBitmap(bitmap, 90);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotateBitmap(bitmap, 180);
break;
}
public static void rotateBitmap(final Bitmap source, int mRotation){
int targetWidth=source.getWidth();
int targetHeight=source.getHeight();
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, source.getConfig());
Canvas canvas = new Canvas(targetBitmap);
Matrix matrix = new Matrix();
matrix.setRotate(mRotation,source.getWidth()/2,source.getHeight()/2);
canvas.drawBitmap(source, matrix, new Paint());
}
Related
I'm try to accomplish the following task:
Selecting an image from Gallery
Rotating the image (if necessary) to the right orientation using ExifInterface
Upload the image to Firebase
Question
If image requires rotation, i'll end up with a rotated Bitmap file. How do i convert this Bitmap file to an Uri so that i can upload to Firebase?
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_INTENT && resultCode == Activity.RESULT_OK) {
mImageUri = data.getData();
try{
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getApplicationContext().getContentResolver(),mImageUri);
rotatedBitmap = rotateImageIfRequired(getContext(), bitmap, mImageUri);
mVideoImage.setImageBitmap(rotatedBitmap);
imageHeight = bitmap.getHeight();
imageWidth = bitmap.getWidth();
}catch (IOException e){
e.printStackTrace();
}
}
private static Bitmap rotateImageIfRequired(Context context, Bitmap img, Uri selectedImage) throws IOException {
InputStream input = context.getContentResolver().openInputStream(selectedImage);
ExifInterface ei;
if (Build.VERSION.SDK_INT > 23)
ei = new ExifInterface(input);
else
ei = new ExifInterface(selectedImage.getPath());
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
return rotateImage(img, 90);
case ExifInterface.ORIENTATION_ROTATE_180:
return rotateImage(img, 180);
case ExifInterface.ORIENTATION_ROTATE_270:
return rotateImage(img, 270);
default:
return img;
}
}
private static Bitmap rotateImage(Bitmap img, int degree) {
Matrix matrix = new Matrix();
matrix.postRotate(degree);
Bitmap rotatedImg = Bitmap.createBitmap(img, 0, 0, img.getWidth(), img.getHeight(), matrix, true);
img.recycle();
return rotatedImg;
}
To upload a bitmap into FireBase storage, you need to turn it into a byte array. You can do this by creating a ByteArrayOutputStream.
ByteArrayOutputStream boas = new ByteArrayOutputStream();
Then compress the bitmap into a format like JPEG or PNG. The compress method takes 3 parameters, the format, the quality, and the ByteArrayOutputStream.
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, boas);
Then create a reference to your FireBase Storage Reference, where you want to put the photo.
String imageFileName = "ExampleName";
StorageReference ref = FirebaseStorage.getInstance().getReference().child("images").child(imageFileName);
Here, I created a folder called 'images' and a file inside which is named using the previously created imageFileName String
Then I can upload it to FireBase using an UploadTask by saying
UploadTask task = ref.putBytes(data);
Using this task, you can create success and failure listeners.
task.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
}
});
I have been trying to save images to Firebase Storage but I noticed that almost all pictures saved from Gallery/Google Drive get rotated.(usually by 90 degrees)
Reading through older posts I realized that this is a common issue and I tried solving it by trying either solution from this post , or from this one , this one and I could go on.
After roughly 8 hours I finally decided to ask here. Is there a better and easier implementation to stop the images from getting rotated?
My last (and unsuccessful, obviously) implementation using ExifInterface (which returns all the time 0) is this one:
Selecting picture
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
OnActivityResult
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
int rotateImageAngle = getPhotoOrientation(getContext(), selectedImage, filePath);
try {
bitmap = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), selectedImage);
// Log.d(TAG, String.valueOf(bitmap));
addPictureButton.setText("Done");
} catch (IOException e) {
e.printStackTrace();
}
if( bitmap != null)
{
RotateBitmap(bitmap , rotateImageAngle);
}
}
Helper methods
public int getPhotoOrientation(Context context, Uri imageUri, String imagePath){
int rotate = 0;
try {
context.getContentResolver().notifyChange(imageUri, null);
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
Log.i("RotateImage", "Exif orientation: " + orientation);
Log.i("RotateImage", "Rotate value: " + rotate);
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}
public static Bitmap RotateBitmap(Bitmap source, int angle)
{
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}
Note: If needed I will add the code that uploads images to Firebase
I have come to a solution thanks to this post.
I am going to post below a modified working version of the code for anybody that has this issue.
Fire up picture selection from gallery
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent, PICK_IMAGE_REQUEST);
OnActivityResult checking original roatation of the selected picture
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) {
// Get selected gallery image
Uri selectedPicture = data.getData();
// Get and resize profile image
String[] filePathColumn = {MediaStore.Images.Media.DATA};
// TRY getactvity() as well if not work
Cursor cursor = getContext().getContentResolver().query(selectedPicture, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
loadedBitmap = BitmapFactory.decodeFile(picturePath);
ExifInterface exif = null;
try {
File pictureFile = new File(picturePath);
exif = new ExifInterface(pictureFile.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
int orientation = ExifInterface.ORIENTATION_NORMAL;
if (exif != null)
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
loadedBitmap = rotateBitmap(loadedBitmap, 90);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
loadedBitmap = rotateBitmap(loadedBitmap, 180);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
loadedBitmap = rotateBitmap(loadedBitmap, 270);
break;
}
imageView.setImageBitmap(loadedBitmap);
}
}
RotateBitmap method
public static Bitmap rotateBitmap(Bitmap bitmap, int degrees) {
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
I am using the following code to get the orientation of the selected image so that if it was taken vertically, when selected from gallery it would not be shown horizontally.
The error is occuring in the
File imageFile = new File(selectedImage.toString()); in the parameter selectedImage.toString()) since when I changed the initial int rotate=90 and chose a vertical image the result was good.
Am I passing the parameter to the File correct?
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
BitmapFactory.Options options;
if (resultCode == RESULT_OK && requestCode == PICTURE_SELECTED) {
try {
options = new BitmapFactory.Options();
options.inSampleSize = 4;
Uri selectedImage = data.getData();
InputStream stream = getContentResolver().openInputStream(selectedImage);
Bitmap yourSelectedImage = BitmapFactory.decodeStream(stream, null, options);
stream.close();
//orientation
try {
int rotate = 0;
try {
File imageFile = new File(selectedImage.toString());
ExifInterface exif = new ExifInterface(
imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
yourSelectedImage = Bitmap.createBitmap(yourSelectedImage , 0, 0, yourSelectedImage.getWidth(), yourSelectedImage.getHeight(), matrix, true); }
catch (Exception e) {}
//end of orientation
imgButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
imgButton.setImageBitmap(yourSelectedImage);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Could not open file.", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getApplicationContext(), "Image was not selected", Toast.LENGTH_LONG).show();
}
super.onActivityResult(requestCode, resultCode, data);
}
Modify your method like this:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
BitmapFactory.Options options;
if (resultCode == RESULT_OK && requestCode == PICTURE_SELECTED) {
try {
options = new BitmapFactory.Options();
options.inSampleSize = 4;
Uri selectedImage = data.getData();
String[] filePath = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePath, null, null, null);
cursor.moveToFirst();
String mImagePath = cursor.getString(cursor.getColumnIndex(filePath[0]));
InputStream stream = getContentResolver().openInputStream(selectedImage);
Bitmap yourSelectedImage = BitmapFactory.decodeStream(stream, null, options);
stream.close();
//orientation
try {
int rotate = 0;
try {
ExifInterface exif = new ExifInterface(
mImagePath);
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
yourSelectedImage = Bitmap.createBitmap(yourSelectedImage , 0, 0, yourSelectedImage.getWidth(), yourSelectedImage.getHeight(), matrix, true); }
catch (Exception e) {}
//end of orientation
imgButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
imgButton.setImageBitmap(yourSelectedImage);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Could not open file.", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getApplicationContext(), "Image was not selected", Toast.LENGTH_LONG).show();
}
}
for image handling compile picasso is best library using it you can easily handle images using it you can load image from cache also and increase performance of your app so try to avoid doing lots of code and add following line in your build gradle and then use picasso in your code.
compile 'com.squareup.picasso:picasso:2.5.0'
Code:
public void buttonLogic() {
Button button = (Button) findViewById(R.id.cameraButton);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
System.out.println("Taking a picture!");
//create intent and send picture through intent as extra, created as temp file on device
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(getApplicationContext())));
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_IMAGE_CAPTURE:
final File file = getTempFile(this);
try {
//retrieve bitmap for picture taken
Bitmap originalBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.fromFile(file));
Bitmap rotatedBitmap = null;
//get exif data and orientation to determine auto-rotation for picture
ExifInterface exif = new ExifInterface("" + file);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
//rotate picture certain # of degrees depending on orientation then sets new matrix
Matrix matrix = new Matrix();
switch (orientation) {
case 3:
matrix.postRotate(180);
rotatedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(), originalBitmap.getHeight(), matrix, true);
break;
case 6:
matrix.postRotate(90);
rotatedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(), originalBitmap.getHeight(), matrix, true);
break;
case 8:
matrix.postRotate(270);
rotatedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(), originalBitmap.getHeight(), matrix, true);
break;
}
Intent i = new Intent(getBaseContext(), PictureActivity.class);
//assigns to global bitmap variable then goes to intent
GlobalClass.img = rotatedBitmap;
startActivity(i);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
}
I've been able to adjust the picture if it gets automatically rotated using EXIF data. But when I take a picture with the front-camera it flips it horizontally. How do I detect if the picture was taken with the front-facing camera so I can flip it back. I have code to flip it back done but not to detect properly if the front-camera was used. Thanks
This question already has answers here:
Why does an image captured using camera intent gets rotated on some devices on Android?
(23 answers)
Closed 4 years ago.
I'm working at an application in android which uses camera to take photos.For starting the camera I'm using an intent ACTION_IMAGE_CAPTURE like this:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File image=new File(Environment.getExternalStorageDirectory(),"PhotoContest.jpg");
camera.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(image));
imageUri=Uri.fromFile(image);
startActivityForResult(camera,1);
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case 1:
if (resultCode == Activity.RESULT_OK) {
selectedImage = imageUri;
getContentResolver().notifyChange(selectedImage, null);
image= (ImageView) findViewById(R.id.imageview);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
image.setImageBitmap(bitmap);
Toast.makeText(this, selectedImage.toString(),
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
.show();
Log.e("Camera", e.toString());
}
}
else
if(resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(EditPhoto.this, "Picture could not be taken.", Toast.LENGTH_SHORT).show();
}
}
}
The problem is that all the photos that are taken are rotated with 90 degrees-horizontally aligned.
I've also put this into my manifest file:
<activity android:name=".EditPhoto">
android:screenOrientation="portrait"
</activity>
But still with no result!So can anyone help me???
http://developer.android.com/reference/android/media/ExifInterface.html
http://developer.android.com/reference/android/media/ExifInterface.html#TAG_ORIENTATION
So if in
Activity.onActivityResult(data, request, result) {
if (request == PHOTO_REQUEST && result == RESULT_OK) {
...
Uri imageUri = ...
File imageFile = new File(imageUri.toString());
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int rotate = 0;
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate-=90;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate-=90;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate-=90;
}
Canvas canvas = new Canvas(bitmap);
canvas.rotate(rotate);
}
Does this help at all?
Just to add to Greg's great answer, here's a whole "category" to do the job:
public static int neededRotation(File ff)
{
try
{
ExifInterface exif = new ExifInterface(ff.getAbsolutePath());
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
if (orientation == ExifInterface.ORIENTATION_ROTATE_270)
{ return 270; }
if (orientation == ExifInterface.ORIENTATION_ROTATE_180)
{ return 180; }
if (orientation == ExifInterface.ORIENTATION_ROTATE_90)
{ return 90; }
return 0;
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
return 0;
}
you'd use it more or less like this ...
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_IMAGE_CAPTURE) // && resultCode == RESULT_OK )
{
try
{
Bitmap cameraBmp = MediaStore.Images.Media.getBitmap(
State.mainActivity.getContentResolver(),
Uri.fromFile( Utils.tempFileForAnImage() ) );
cameraBmp = ThumbnailUtils.extractThumbnail(cameraBmp, 320,320);
// NOTE incredibly useful trick for cropping/resizing square
// http://stackoverflow.com/a/17733530/294884
Matrix m = new Matrix();
m.postRotate( Utils.neededRotation(Utils.tempFileForAnImage()) );
cameraBmp = Bitmap.createBitmap(cameraBmp,
0, 0, cameraBmp.getWidth(), cameraBmp.getHeight(),
m, true);
yourImageView.setImageBitmap(cameraBmp);
// to convert to bytes...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
cameraBmp.compress(Bitmap.CompressFormat.JPEG, 75, baos);
//or say cameraBmp.compress(Bitmap.CompressFormat.PNG, 0, baos);
imageBytesRESULT = baos.toByteArray();
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
return;
}
}
Hope it saves someone some typing in the future.
The above answer is very thorough, but I found I had to do a little bit more in order for every case to work, especially if you're dealing with images from other sources such as the Gallery or Google Photos. Here's my DetermineOrientation method. I have a utility class where this is located so I have to pass in the Activity in order to use managedQuery(which btw is deprecated so use cautiously). The reason I have to use two methods is because, depending on the source of the image, ExifInterface will not work. For instance, if I take a camera photo, Exif works fine. However, if I'm also choosing images from the Gallery or Google Drive, Exif does not work and always returns 0. Hope this helps someone.
public static int DetermineOrientation(Activity activity, Uri fileUri)
{
int orientation = -1;
int rotate = 0;
try {
ExifInterface exif = new ExifInterface(fileUri.getPath());
orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
rotate = 0;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(rotate == 0)
{
String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
Cursor cur = activity.managedQuery(fileUri, orientationColumn, null, null, null);
orientation = -1;
if (cur != null && cur.moveToFirst()) {
orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0]));
}
if(orientation != -1)
{
rotate = orientation;
}
}
return rotate;
}