How to rotate image without reducing its quality? - android

I want to load an image from camera folder, but image has different orientation (rotated).
So I rotate it. When I create new file to save rotated image, the quality of that image is reduced.
I tried create new file from origin file without rotating it,
but quality image still reduced.
I think that image quality gets reduced when save image.
Issue: Rotating an image reduces image quality.
Any idea would be greatly appreciated.
Thanks

Related

Implementation for custom image cropping in Android

I need to implement the custom image cropping instead of using the system cropping (i.e. "com.android.camera.action.CROP"). I need to know the exact position of the cropping bounding box but this information is not retrievable if I choose to use the default cropping. Besides, the bitmap image is down sampled too much by default cropping.
The steps are as following:
Create the original size bitmap from source (using uri). The
original size is about 4000x3000 which is too big.
The user defines the crop area to extract the ROI which results in resizing of the original image to fit the ImageView. (size of ImageView is about 700x700)
Record the position of the bounding box in the ImageView.
Retrieve the cropped area from the original image and create another bitmap for it.
Resize the cropped bitmap to fit the imageview size to show it on the screen.
This approach works on my device (ZTE nuoio with Android 4.3) well. However, the app crashes on Samsung S4 with Android 4.4.4 and Note 4 while performing step 1 probably because of the out-of-memory error.
Therefore, I try to do another approach that creates the bitmap which is down sampled from the source image, rather than having the original size bitmap image.
I need to have the information of the exact position of cropped area from the original image. That is the reason why I didn't use default cropping. Could you please help me out with my case either providing
the solutions to derive the exact coordinates of the bounding box of the cropped image in the original image as a matrix.
how to solve the out-of-memory error in step 1 using the approach I mentioned above.
Or other approach to achieve image cropping with knowing the exact coordinates of cropped area form the original image.
Thank you so much.
For Crop an image and get Coordinates use library Edmodo Croper https://github.com/edmodo/cropper
For Out of memory issue you have to down scale image.

Portrait Image rotated on crop view

When I take a picture in portrait mode, the crop view automatically rotates it by 90 degrees. Does not seem to happen in landscape. Is there a way to prevent this
Change the file type from png to jpg
EDIT: Comments from Charles Caldwell, which explain why this answer is correct: "PNG files do not contain EXIF data which includes the rotation information. If the photo is taken as a PNG, switching to JPG could resolve the issue"

how to edit big images in android?

I am trying to save small images from the original which I load from SDcard. Android doesn't allow me to create bitmap of bigger image sizes so I had to use options, doing so my images' resolution is altered so now how i am supposed to edit the original image??
And saving images, do I have the bitmap.compress option alone? If so, this reduces the quality of the image when i open and save it in JPG
And how can I display them independent of the screen???
I found a way to display big image in Android by using BitmapRegionDecoder. http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html

Is there a way to crop a large image on android without loading into memory?

I don't want to display the bitmap on the screen. Just trying to create a max square image out of the original image from sdcard and then uploading to server. Is there a way to crop an image without loading the image into memory? or load the image in chunks and then save to file?
I don't know if I understand well the question but this could help:
http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
Hope to help :)

loading a bitmap to the "right" size

i want to load a bitmap off the SD card and display it. the image on the SD card is 2592x1728, and i want to display this image in a 200x200 pixel image. when i load the image, obviously, I don't want to load the entire image into memory (2592x1728x3 bytes!). is there a way to automatically load it into the right size?
Take a look at this snippet. Its about as good as it gets. You will have to read over the whole image at least once, but you can scale it down to a Bitmap object that is a little bit less cumbersome to work with.
Strange out of memory issue while loading an image to a Bitmap object

Categories

Resources