Crop and center an avatar in Codename One allowing the user to choose the region to crop - codenameone

About cropping and centering an avatar in Codename One, I saw similar examples in the manual, in the Javadoc and in the blog, for example the first block of code here:
https://www.codenameone.com/javadoc/com/codename1/capture/Capture.html
But I need something that is different and more difficult.
The main problem is that the face is not always in the exact center of the photo. Some apps allow the user to choose the region to crop.
For example, suppose that after capturing a photo it looks automatically cropped and centered so:
Of course it's wrong, I want the lion at the center. In this case, it could be nice if the user can pinch-to-zoom the lion and drag it to the center of the cropping area, getting something like this:
I don't know where to start to do this with Codename One. Is it possible to do it with a Form shown immediately after capturing a photo, that allows to pinch-to-zoom and center the photo in the cropping area like in the above image? Thank you for suggestions.

This is non-trivial but we probably should have a standardized component that does that. Generally the best approach would be to have an ImageViewer as a layered layout component and an overlay mask on top. This is pretty easy to implement.
The hard part is cutting the image correctly based on the scale/pan values from the ImageViewer class.

Related

How to go about changing the tint color of an image?

Sorry for the vague title, I have no idea how to really ask this question to be honest so I'll describe what I'm trying to do
I'm attempting to make an app where users can change the colors of different parts of a car. They can change the door for instance to a green as shown, or any other color they wish. They would then be able to change the color of the hood, or the roof, etc.
I've thought about having seperate images for each component and then lining them up to match. However this seems practically impossible when it comes to different screen sizes and scales. I also thought about making a blanket white image, and then creating views over the top with the selected color.
Does anyone have any ideas how I could possibly approach this?
Thankyou
I dont know about the performance of this. But, how about, an overlay of the different parts of the car, but using the same size of the whole car. For example, you have the image of the whole car, and erase all but the door. In other image, you erase all but the hood. If you lay one image above another, it will make the whole car, and the size of the screen will not affect you, because all the images will have the same size.
Then you can use the tint style to change the color of each layer.

Codename one customizing capturing image from camera

First of I would like to thank the codename one team for the support to get me through some of the tough tasks I have faced. Now that I have solid app that I am ready to submit to the app store, I would like to know bit more detail or any examples of how the capturing photo can be cropped.
If I want to capture an photo using the camera, I want to crop it to desired width and height of the photo. Is there any example to crop the image and show the cropping area while taking picture?
Please advise.
Thank you.
Thanks!
You can use Image newImage = myImage.fill(desiredWidth, desiredHeight); this will retain aspect ratio and crop the redundant areas.

silverlight map application like showcase on silverlight.net

we want to make application like silverlight showcase Mapview
where we can search by different category on left hand side panel or people can select country or region on map. can anyone suggest some sample or guidelines to implement this?
Thanks
Given the complexity and obvious expense, I would be really impressed if anything like that was released as a sample (Microsoft are you listening?). It requires a lot of data to drive it.
I have been involved in creating a Xaml World map from scratch (below) and that alone took nearly a day for a stylised polygon version (no fine detail)....
Quoting myself: "You import a map as a background image and use the pen tool to dot-to-dot trace around the country. Combine all those path segments into a single path. Then create a separate poly-path for each state (close them to allow for a fill)."
Once you create them you can name the individual country polygons and connect up mouse logic to make them all glow on mouse over or change colour on press etc.
Basically all the other stuff on that screen are user controls and custom controls. Work out the behaviour you want and create controls to suit your own needs.

Some animation requests in a Silverlight application

I am making a flash card application. It shows the question and then a textbox for user input, all wrapped in a border or rectangle. So what I want is an animation that "flips" the rectangle or border upside-down and then their is text on the "back". Also, I want my application to APPEAR transition from one card to another by "flying off" the screen then "another" card comes in to replace the other one in the opposite direction. But actually I'm want just a little animation of the border or rectangle moving off the screen then coming back in, but in the opposite direction. Some help would be appreciated, like what kind of animation can accomplish this and maybe a small code sample to demonstrate. I am not asking you write all this, I think that would be a little rude (unless you really want to).
Have you had a look at the Silverlight FX stuff? There might be some animations in there that are what you are looking for. There are also samples provided.
http://projects.nikhilk.net/SilverlightFX
Michael

MultiScaleImage Zoom Particular Areas

I am trying to create a Deep Zoom based multiscale image that essentially has 2 views. Initially it will display a large map of the world. When the user click the USA the image should then zoom into the USA. Clicking an external button should zoom the image back out. Thats it. I don't want panning or additional zooming.
What I don't understand is how to define a "hit area" around the USA that zooms it in. Can anyone provided links to resources that explain how to do this... I never seem to find exactly what I am after?
Thanks in advance.
I can't remember the code exactly.
But if you generate a project with the source code in Deepzoom composer and then take a look at the source code.
Right down the bottom of the the Deepzoom code is a function for zooming into a LogicalPoint.
Convert the top left point of the image you are zooming into a logical point. Set this as your ViewportOrigin as this will put it in the top left.
http://blogs.msdn.com/jaimer/archive/2008/06/23/working-with-collections-in-deep-zoom.aspx This post here explains the ViewportOrigin quite well. Just remember that everything is related to the Width.
You will also need to set the the ViewportWidth.
When the ViewportWidth = 1 the whole image is displayed so it will be a fraction of the total width of the image. (USA width / WorldMap Width)
Hope this makes sense.

Resources