Problem with setting the orientation of the image
Is my second question on this topic today but on the previous one it seems I haven't been clear enough.
I have an activity where I'm building my own camera in order to take pictures.
In the onCreate()
method of this activity I'm doing something like:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
otherwise my whole screen looks like this: .Anyway this solves my issues for the moment and the image is looking good.
After taking the picture I'm using a bundle and send the image to another activity(Activity B) where I edit the picture and after that save the image to a website.
And here is the problem: The picture received in this activity is again orientated wrong like here: ![enter image description here][1] because I haven't done any operations upon the image itself, only on the activity orientation.
Now, I could do in here barely the same thing and set the activity in the LANDSCAPE
mode and my activity would be looking good again, but further more when I upload the image to a website this would look wrong on the website for the simple fact that I haven't done anything to set her own orietntation.
So, in my surfaceChanged()
- in the activity A
, the first one, method I've don开发者_JAVA百科e something like this:
Camera.Parameters p = mCamera.getParameters();
p.set("orientation", "landscape");
p.setRotation(90);
mCamera.setParameters(p);
But this has no effect on the image, it looks the same.
I'm working on Sony Ericsson
and need help on rotating my image-not setting up the orientation of my activity
!
Thank you, I'm here for further details.Thanks
EDIT:
In activity A
where I'm taking the image I'm doing this:
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback(){
public void onPictureTaken(byte[] imageData, Camera c) {
if (imageData != null) {
Intent mIntent = new Intent();
//StoreByteImage(mContext, imageData, 50, "ImageName");
mCamera.startPreview();
Bundle b = new Bundle();
b.putByteArray("imageData", imageData);
Intent i = new Intent(mContext,ImageDisplayActivity.class);
i.putExtras(b);
startActivity(i);
setResult(FOTO_MODE, mIntent);
finish();
}
}
};
And in activity B
where I'm receiving the image I'm doing this:
Bundle extras = getIntent().getExtras();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5;
byte[] imageData = extras.getByteArray("imageData");
Bitmap myImage = BitmapFactory.decodeByteArray(imageData , 0, imageData.length,options);
....///is set up the bitmap to an imageview
Ok I have a hunch that you are overestimating the problem!
Try to rotate myImage
before uploading
Matrix mat = new Matrix();
mat.postRotate(90);
image_to_upload = Bitmap.createBitmap(myImage, 0, 0, myImage.getWidth(), myImage.getHeight(), mat, true);
Try different angles I am sure this is the issue and you will find the right path
精彩评论