Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Taking Picture Orientation Issue

Hello all,

 

I am showing the camera using ForeignWindowControl and I am also following SeanMcVeigh's sample on camera rotation to always keep it upright.

 

My problem is that even though the ViewFinder rotates on screen to corrct orientation, when I snap images, the images orientation seems wrong (upside down or rotated to side) when I insert them into a custom thumbnail list. (I say seems wrong because when I open it in media previewer it display correctly - goes to correct angle but doesn't display correctly on my laptop when I export the image).

 

Could anybody please give me a hint with this because I have followed the camera rotation sample very closely and I can't see anything I am doing diffferently.

 

Thanks.

 

Danielle.

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Taking Picture Orientation Issue

Anybody know why the image snapped is not at the same angle as the viewfinder is being displayed at?

 

I record videos including same camera rotation code and they seem to have correct orientation both previewing in my custom thumbnail list and when playing the video.

 

The photos I take however are previewed (thumbnailed) upside down unless I have the blackberry logo right side up when snapping the pic andthen  it is previewed correctly in list but then displayed incorrectly when I open the file with a card.

 

I have spent days on this already and really need to move on - Please can somebody help me?

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Taking Picture Orientation Issue

As I recall, the rotation sample I published was for videos.

In photo mode, you can usually ignore any CAMERA_IMGPROP_ROTATION settings if all you are interested in is saving JPEGs.

 

There is a function called camera_set_device_orientation() which can be used to tell the camera which way the device is being held.  It will take this information and stick it into the appropriate EXIF tag so that image viewers will display the photo correctly.

 

camera_set_device_orientation(handle, 90);

 The above example indicates to the camera that you are holding the device rotated 90 degrees clockwise (BlackBerry logo is now at the 9:00 clock position).  Photos will still be saved in the native pixel orientation, but a photo viewer will understand that it has to decompress the JPEG in a rotated manner to match the capture orientation.

 

Cheers,

Sean

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Taking Picture Orientation Issue

Thank you for your answer Sean.

 

You are right - the sample is for rotation whilst recording video and there is absolutely nothing else which shows how to do this for taking a picture (searched/experimented for nearly 3 days on this).

 

So I am trying to folow exactly what the video rotation sample does - rotate the viewfinder to keep it correctly upright at all times which both viewfinders (video & photo) are doing. Just by following the video rotation sample it seems to be correct.

 

My problem is that I am trying to keep a cache of thumbnails for my preview list and when I load these preview images into the list they aren't upright but then they are when I invoke preview card on the file.

 

I learnt about exif yesterday and realised thats why media viewer app was able to show the image upright but then I still didn't get a solution so another day on this is planned.

 

So if exif header is being put in the file correctly (as it seems) should I keep my camera code the way it is and be looking at a way to parse the image correctly when loading into list or is there a problem with my taking picture code do you think?

 

Appreciate any help on this as already mentioned - losing DAYS on it!

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Taking Picture Orientation Issue

Finally solved this by using libexif to parse the header to find out orientation when image was captured and then I rotated my thumbnail (to be displayed in list) to the correct orientation before saving.

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Taking Picture Orientation Issue

glad you've found a solution.

 

I definitely do intend to get a photo rotation best-practises sample published as well.. it's just that someone was asking about video at the time :smileyhappy:

 

When I started on this, we had one hardward platform, and it supported rotatable photos (using CAMERA_IMGPROP_ROTATION).  In that case, there was no need to look at EXIF because the photos were always upright.  But then new hardware came along which did not support this, and we had to fall back on using EXIF for photos.  You can still set a physical photo rotation, but it's not guaranteed to work on all platforms (you can query the capabilities).

 

As a side note.. lots of other platforms rely on EXIF in these cases as well (you may notice that Android, for example, has no concept of rotatable buffers.. recording videos on these devices produces sideways video files in some players.  iOS gets around this by doing essentially the same EXIF trick, but stored in the .mov files.  Since we are generating compliant MP4 files on BlackBerry 10, and since the MP4 standard doesn't currently support such extra metadata, we went the extra mile and made the video buffers rotatable)

 

Cheers,

Sean

Please use plain text.