Codenameone Capture Photo Upside down - codenameone

using the Capture class to take photos using the front facing camera (Selfie Camera) on android, the photo comes out upside down. Is there any way we can detect that the front facing camera was used so we can rotate the image if needed?

Some cameras capture the image in the orientation of the camera sensor then mark it with a special rotation flag in EXIF to indicate that the image should be viewed in a different orientation. This is common in the back camera that always captures in landscape and marks portrait images as rotated.
When you open an image using Image.createImage(filePathToImage) we implicitly detect EXIF data and adjust the image so it will be viewed correctly. Other image loading methods don't work the same way. This highly depends on the Image API you used and the Capture call you made as there are few variations of both.

Related

Is it possible to change user's phone orientation using react?

I have the next question. I am developing a react application with some images. The user has the possibility to click and open a full-page image. Because the image's orientation is horizontal on the mobile, it does not look good. My idea is when the user clicks on the full page icon, the orientation of the phone becomes horizontal as is implemented on youtube. I tried to find some information about that, but I am not sure if it is even possible, I saw that only by using react native and developing mobile applications you can have access to the user's orientation of the screen. But maybe there are some methods to do in the browser? Thanks in advance.
It is not possible to change this from the web, however you could simply rotate the image and display it full screen. This has been done here:
CSS Rotate Portrait Image 90 Degrees and Make Image Full Screen

Autodesk Forge Viewer fit to view portrait/landscape

I have a Forge viewer app where I want the camera to fit the model bounding box if the orientation on mobile devices changes.
I load the model and set the camera to a specific position in the Autodesk.Viewing.MODEL_ROOT_LOADED_EVENT event. Then I fit the model with viewer.fitToView(). That works.
In the Autodesk.Viewing.VIEWER_RESIZE_EVENT, which is also fired if the orientation of the screen changes, I run viewer.fitToView() again but the camera doesn't change.
The function doesn't seem to even run, but there is also no error message. If I zoom out of the model before changing the orientation the camera distance doesn't change although it should.
Maybe I use the wrong approach here but I can't find the problem.
Found the problem: I have locked panning of the camera:
viewer.navigation.setLockSettings({"orbit":true, "zoom":true})
viewer.navigation.setIsLocked(true)
With those settings fitToView doesn't work. I now disable locking before fitting.

manual zoom in the enlarged image window

I would like to have the option of manual zoom in the enlarged image window on the mobile device. So that I can zoom into the displayed image within the Javascript frame. I do not want to zoom the whole web page. Is that possible? Or is there another Javascript that can do this?
It is not possible to zoom the enlarged image in Lightbox or Lightbox2. There is no such feature.
To do that, you should use a different zoom script, such as Magic Zoom Plus.

Custom action after tapping a video during the playback or when the playback ends

My use case: I have an image that is the preview of a video. When the user tap the preview, the video should starts a fullscreen playback (I suppose in another Form). When the video ends or when the user tap the video during the playback, the previous Form should be shown. This is the same use case of the question: Codename One landscape oriented Form in a portrait locked app
My question: the MediaPlayer class doesn't seem to expose a method to perform a custom action when pressing the video or when the video ends, like requested by this use case. The MediaPlayer is a peer component, so I'm not sure if trying to use a button as a leader component can make sense to do an action after a tap. Any idea?
Unfortunately media is pretty complicated in that sense. You can either rely on the behavior of the media player natively which handles orientation change, playback etc. seamlessly (seek etc.). Or you can implement everything on your own in a media object in which case you can use native peer overlay and have a transparent component on top of the media view which will grab all the clicks.
The former will provide a more native UX and will auto-rotate the UI but we don't have control since there's no Form underlying the UI. It's shown when you invoke setNativePlayerMode(true). When you tap the video in this case it pauses. To exit playback you would use device native keys e.g. back or a done button and would be returned to the parent Form. Notice that since this is native behavior it acts differently on the device and it's important to do device testing here.
Your alternative is to place a media component in the center of the screen and then you can override everything and customize everything. You can place a layered layout on top and grab all tap events. You will need to add your own progress, play, pause etc. UI elements. The user would need to physically rotate the device as orientation won't switch on its own (for the most part).

How to develop multi paint (on maps)

I want to develop a multi-paint: An application, which each user can paint route on a map, save the route, and in the end all the saved routes will be "merged" into one big picture (like layers in photoshop)
How should I save the routes? List of pixels to be drawn? Save it to picture (with transparent background?)
The application will be developed in WPF on bing maps (on touch device).
Thank you very much
You would have to save the latitude and longitude values of the route points, perhaps in a LocationCollection, which is part of the Bing Maps WPF Control API.
Simply saving the pixels wouldn't work when you want to be able to zoom the map.

Resources