The actual rotation of a full-resolution image is not trivial, but
drawing it with the correct rotation/orientation is not that hard.
Just use a Matrix holding the rotation and assign it to the canvas on
which the image is drawn.

On Dec 21, 6:45 pm, Mark Wyszomierski <mar...@gmail.com> wrote:
> Alright thanks all, got this working. On 2.0+ devices, I use the
> ExifInterface class to see if the image needs to be rotated. If so, I
> can load the image at a downsampled size and do the rotation myself.
> Like Streets Of Boston pointed out, I don't know of a good way to do
> the rotation of the full high-res image.
>
> Thanks
>
> On Dec 21, 1:16 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>
>
>
> > Check by using the content-provider. Do a query on the image-id (can
> > be obtained from the image-Uri) and request its value of the column
> > 'MediaStore.Images.ImageColumns.ORIENTATION'.
>
> > About #2: Yep, doing that in the device using full-resolution will be
> > hard to do. Not enough memory available for that. You could do it by
> > using a file (RandomAccessFile) as a 'temporary', writing column by
> > column to this file and reading it back in row by row. This will be
> > very slow.
>
> > On Dec 21, 11:59 am, Mark Wyszomierski <mar...@gmail.com> wrote:
>
> > > Hi Wu-Cheng,
>
> > > I'm not following - I'm using the native camera intent with the Droid.
> > > So if I take a picture while holding the camera in a portrait
> > > orientation, then it should write a rotation of 90 degrees into the
> > > exif header of the output jpeg (while not really rotating the image
> > > data)? If that's the case, I'm not sure how to proceed. Looks like I
> > > would have to do the following:
>
> > >   1) Check the exif header to see if this rotation parameter exists
> > >   2) If it does exist, rotate the image myself before display
>
> > > #1 could probably be done using the ExifInterface class, but that's
> > > only been added to the level 5 sdk, while I'm targeting sdk 3 and
> > > above.
> > > #2 could also be done after a lot of downsampling. I'm not sure if
> > > other applications understand exif headers though. So I'd want to
> > > rewrite the image data with an actual rotation. Doing this at full
> > > resolution would be difficult on the device.
>
> > > Thanks for your help.
>
> > > On Dec 21, 10:37 am, Wu-cheng Li (李務誠) <wuchen...@google.com> wrote:
>
> > > > Droid respects setRotation. The problem is Droid does not rotate the 
> > > > entire
> > > > picture. Droid only sets orientation in the EXIF header. Applications 
> > > > need
> > > > to check the orientation in the EXIF header and then rotate it 
> > > > accordingly
> > > > before display.
>
> > > >http://developer.android.com/reference/android/hardware/Camera.Parame...
> > > > public void setRotation (int rotation)
> > > > Sets the orientation of the device in degrees. For example, suppose the
> > > > natural position of the device is landscape. If the user takes a 
> > > > picture in
> > > > landscape mode in 2048x1536 resolution, the rotation should be set to 
> > > > 0. If
> > > > the user rotates the phone 90 degrees clockwise, the rotation should be 
> > > > set
> > > > to 90. Applications can useOrientationEventListener to set this 
> > > > parameter.
> > > > The camera driver may set orientation in the EXIF header without 
> > > > rotating
> > > > the picture. Or the driver may rotate the picture and the EXIF 
> > > > thumbnail. If
> > > > the Jpeg picture is rotated, the orientation in the EXIF header will be
> > > > missing or 1 (row #0 is top and column #0 is left side).
>
> > > > The problem is not related to set("rotation", 90) or setRotation(90). 
> > > > They
> > > > are the same except setRotation only exists from 2.0.
>
> > > > On Sun, Dec 20, 2009 at 1:48 PM, Mark Wyszomierski <mar...@gmail.com> 
> > > > wrote:
> > > > > It looks like what I might have to do is switch my project to the 2.0
> > > > > sdk (it's currently at 4). If I see that the OS level my app is
> > > > > running on is less than 2.0, then I make this call:
>
> > > > >  Camera.Parameters params = camera.getParameters();
> > > > >  params.set("rotation", 0);
> > > > >  camera.setParameters(params);
>
> > > > > if it's 2.0 or above, I use this call (added in the 2.0 api):
>
> > > > >  Camera.parameters.setRotation(int rotation);
>
> > > > > is this probably the best way to go? I don't know if I could go the
> > > > > other direction (stay at sdk level 4, and if I see the user is running
> > > > > 5, try to somehow invoke the 2.0 api which should be present),
>
> > > > > Thanks
>
> > > > > On Dec 19, 9:09 pm, Mark Wyszomierski <mar...@gmail.com> wrote:
> > > > > > Thanks, just posted there too. I hope there's a way to get around 
> > > > > > this
> > > > > > innovation in camera.parameters..
>
> > > > > > In the worst case, I guess I could check what platform the user is
> > > > > > running on, and use the native camera intent?
>
> > > > > > Thanks
>
> > > > > > On Dec 19, 8:55 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
> > > > > > > Mark Wyszomierski wrote:
> > > > > > > > I got all the parameters from a Droid for the camera - looks 
> > > > > > > > like
> > > > > > > > rotation is not one of them... how do you get the camera to 
> > > > > > > > rotate
> > > > > the
> > > > > > > > output?:
>
> > > > > > > > picture-size-
> > > > > > > > values=1280x960,1600x1200,2048x1536,2592x1936,2592x1456;mot-postview-
> > > > > > > > mode=on;zoom=0;antibanding=auto;zoom-
> > > > > > > > supported=true;whitebalance=auto;jpeg-thumbnail-height=240;scene-
> > > > > > > > mode=auto;jpeg-quality=95;smooth-zoom-supported=true;preview-format-
> > > > > > > > values=yuv422i-yuyv,yuv420sp;focus-mode=auto;preview-
> > > > > > > > format=yuv420sp;mot-test-command=;mot-zoom-step=0.5;preview-
> > > > > > > > size=560x320;picture-format-values=jpeg,jfif,exif;mot-areas-to-
> > > > > > > > focus=0;mot-postview-modes=off,on;flash-mode-
> > > > > > > > values=off,on,auto;preview-frame-rate-values=5,10,15,20,24,25,30;mot-
> > > > > > > > max-areas-to-focus=1;preview-frame-rate=30;flash-mode=off;effect-
> > > > > > > > values=none,mono,sepia,negative,solarize,red-tint,blue-tint,green-
> > > > > > > > tint;focus-mode-values=off,auto,infinity,macro;picture-
> > > > > > > > size=2048x1536;max-zoom=6;effect=none;jpeg-thumbnail-
> > > > > > > > width=320;whitebalance-values=auto,daylight,fluorescent,cloudy-
> > > > > > > > daylight,incandescent,warm-fluorescent;scene-mode-
> > > > > > > > values=auto,action,portrait,landscape,night,night-
> > > > > > > > portrait,theatre,beach,snow,sunset,steadyphoto;picture-
> > > > > > > > format=jpeg;jpeg-thumbnail-size-
> > > > > > > > values=160x90,160x120,176x144,320x180,320x240;mot-zoom-
> > > > > > > > speed=99;preview-size-
>
> > > > > values=176x144,320x240,352x288,640x480,720x480,720x576,848x480;antibanding-
> > > > > > > > values=auto,50hz,60hz
>
> > > > > > > If your problem is unique to the DROID, you may get more 
> > > > > > > assistance by
> > > > > > > posting at the MOTODEV boards:
>
> > > > > > >http://developer.motorola.com
>
> > > > > > > Forgive me if you've already tried that...
>
> > > > > > > --
> > > > > > > Mark Murphy (a Commons Guy)http://commonsware.com|
> > > > >http://twitter.com/commonsguy
>
> > > > > > > _Android Programming Tutorials_ Version 1.0 In Print!
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > > > >  cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en-Hidequoted 
> > > > >text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to