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

Java Development

Reply
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Storm/Torch camera getSnapshot() orientation issue

As most of you must know, there is a bug on Storm/Torch devices where a picture taken from the getSnapshot() method of the video control is automatically rotated 90 degrees to the right.  There are multiple posts on this issue, and it is logged in the issue tracker: https://www.blackberry.com/jira/browse/JAVAAPI-701

 

Has anyone found a workaround for this issue?  I have tried setting the application to portrait mode only (as some suggested), but this does not fix the problem.  I'd appreciate any ideas, known workarounds, or suggestions.

 

Thanks!

Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Storm/Torch camera getSnapshot() orientation issue

[ Edited ]

It's not a bug, it's a feature :smileyhappy:

They only work properly when pictures are taken in landscape mode.

Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Storm/Torch camera getSnapshot() orientation issue

dnepr,

 

Can you clarify for me a bit?  When I take a picture from within my application and the device is in portrait mode, I then construct a bitmap with the image and it appears sideways (rotated 90 degrees to the right).  The resulting image does not look straight unless when I take the picture, the device is rotated 90 degrees left (landscape).  

 

So when it is in portrait mode, as you say, the image is rotated and does not appear straight...

Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Storm/Torch camera getSnapshot() orientation issue

I'm sorry, Landscape! Don't know what I was thinking when I typed that :smileysad:
Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Storm/Torch camera getSnapshot() orientation issue

So perhaps I will try setting the application to landscape mode (Display.DIRECTION_EAST) when the camera screen is open, and then changing it back?  But if you take the picture in lanscape mode, but 90 degrees to the right (instead of the left), then the resulting image is upside down.  You would think that this wouldn't happen if pictures were meant to be taken in landscape mode.  Plus, a resulting picture taken in portrait mode on the device's native camera will appear correctly in portrait...

 

It seems silly to have to notify the user to hold the camera a certain way to take a picture.  I'd also have to put in a conditional statement saying to ONLY lock the application in landscape mode when the device resolution is W x H...

Please use plain text.
Developer
StevenKader
Posts: 634
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Storm/Torch camera getSnapshot() orientation issue

Here is some code that I use to identify what the orientation of the picture is from the  metadata in the image itself.  Depending on the orientation i rotate it if it needs to.   I do scale it down a bit before rotating which you may or may not want to do.  Hope this helps.

 

byte[] raw = null;
					try {
						raw = _videoControl.getSnapshot(null);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

					EncodedImage fullImage = EncodedImage.createEncodedImage(raw, 0,
							raw.length);

					MetaDataControl m = fullImage.getMetaData();

					String orientation = "";
					try {

						orientation = m.getKeyValue("orientation");
					} catch (Exception e) {
					}
					
				
					
					Bitmap bmp1 = Bitmap.createBitmapFromBytes(raw, 0, -1, 3);
					Bitmap bmp  ;
					
					if (orientation.equals("6")) {

						bmp = ImageManipulator.rotate(bmp1, -90);
						
					}
					else
						
						
					
					if (orientation.equals("3")) {

						bmp = ImageManipulator.rotate(bmp1, -180);
		

					}
					else
						bmp = bmp1 ; 

 


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: Storm/Torch camera getSnapshot() orientation issue

Where is the class ImageManipulator?


Please use plain text.
Developer
StevenKader
Posts: 634
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Storm/Torch camera getSnapshot() orientation issue

Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Storm/Torch camera getSnapshot() orientation issue

Let me know if you get this code working, I was unable to.

Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: Storm/Torch camera getSnapshot() orientation issue

I never got it to work
Please use plain text.