Codename one customizing capturing image from camera - codenameone

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.

Related

Mapbox raster image not working in mobile

In mobile view mapbox renders black image instead of raster image. I suspect this is because of the size of image(3.9 MB), also this is happening mostly on chrome browser for mobile. Please help me find the potential issue here?
This sounds as if you could be running into the No-Data issue, when rendering transparency.
The black background that appears is the part of the raster image that does not contain any data. Generally a raster image is a rectangular grid of pixels. When you are working with data that is not rectangular, there are pixels within the grid that don't contain any data. These pixels are expressed as NoData values and represent the absence of data. GeoTIFFs that are uploaded to Mapbox Studio are displayed as JPEG to save space and make maps load quickly. Since JPEG cannot display transparency, NoData values appear black.
Please see this documentation on how to resolve this:
https://docs.mapbox.com/help/troubleshooting/raster-transparency-issues/#why-black-backgrounds-appear

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

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.

How ImageResizer Dynamically change image resolution based on screen size

I am using ImageResizer to resize the images and display on the bootstrap layout.
Here I am fixing the image sizes while retrieving them to display the sizes in URL.
Issue is, image quality is lost as dimensions are different for different screen sizes and I am unable to adjust the image which is retrieved to fit exactly to the screen size.
Eg: for 14 inch monitor if size of image is 300*300 which gives perfect quality image, if the same image is viewed in 21 inch monitor the 300*300 image retrieved from imageresizer is loosing quality and getting blurred.
Can some one say what is best solution to retrieve images?
Thanks in advance.
Praveen.
Slimmage.js offers automatic resolution and dpi-switching using the ImageResizer URL API. It is probably the easiest way to achieve what you are looking for, as you just install it and set a CSS max-width on images. Done.
Why this is a problem (like Amy says in the first comment):
Because of high-density displays, browser pixels and screen pixels are not 1-1. Thus you need to use a images-swapping technique like srcset, picture, or Slimmage.js. srcset and picture require polyfills to work on older browsers.

I am trying to save images in wpf application, but after saving some reddish tint color is coming on that images

I am trying to save images in wpf application, but after saving some reddish tint color is coming on that images and also losing sharpness of those image. I am using PNGBitmapEncoder for that and saving imags in PNG format. I dont know what is happenning.
Anybody Plz give me the solution.. I am trying from so many days. Plz help me regarding this issue.
Thanks in advance
You'll need to post your code and possibly an example of what the incorrect image looks like.
The most likely explanation is that you've got a mis-match between the order of red green & blue pixels in memory vs what the file format is expected, or that the red value is being increased at the expense of the green & blue somehow.
Are you trying to resize the image as well? That might explain the blurriness.

Resizing a Silverlight or Flash video player?

Is it possible to resize a silverlight/flash video player on the fly? I would like to create a video where I can drag the bottom left corner to resize the player (maintaining aspect ratio) or at least eliminate the possibility of doing so I could move on to other methods.
Thanks in advance...
EDIT: // forgot to mention
Sorry forgot to mention, this would also mean that the actual video itself resizing right?
Silverlight: Absolutely. Just set the the Stretch property to Uniform and then alter either the Width or Height as you resize.
Flash: Yes, you can alter the size of a flash object through JavaScript. Using a YUI, jQuery, or a Mootools JavaScript library, this should not be too difficult to prototype.
Here is a posts which explains how to resize flash from within your flash code.
Proportional resizing - here is an example of that as well using jQuery.
I'm not sure if the same is true for Silverlight browser objects, although I'd be surprised if you couldn't do the same.
This is a CSS solution for resizing videos on the fly.
The video can even resize itself according to the user settings if it is styled using EMs. This demo shows how a video resize itself according to the width of the user agent.
Here is an example of the silverlight scaling. This photo retouching and restoration site has a couple of silverlight controls that scale with browser resizing. There is quite a nice photo gallery that shows the photos before and after the retouch.
JWPlayer
As of version 5.3 they added a resize() method to the javascript API which allows you to resize a player - and all the control bar etc. will resize correctly too.
http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12540/javascript-api-reference
resize(width, height) Resizes the
player to the specified dimensions.
width:Number: the new overall width of
the player.
height:Number: the new
overall height of the player. Note: If
a controlbar or playlist is displayed
next to the video, the actual video is
of course smaller than the overall
player.

Resources