When I load an image from gallery in my android application, why does the bitmap return a smaller image? - android-camera

I am capturing an image from the camera of an android phone and saving it in the gallery. When I am loading the image from the gallery, the resultant image is always smaller than the original image. Can anyone tell me how to resolve this issue?
Picture in gallery is:
The picture inside the android application when loaded from the gallery is:
I am using the following code to load the image into the imageView:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
final Bitmap capturedimage1 = BitmapFactory.decodeFile(uri, options);
BitmapDrawable ob = new BitmapDrawable(getResources(), capturedimage1);
//capturedImg is the imageView and capturedimage1 is the bitmap image loaded from gallery
capturedImg.setImageBitmap(capturedimage1);

Becasue you choose inSampleSize=2.

Related

Convert camera capture image like camscanner image flutter

I have implemented a app to capture image from camera and convert it to pdf and share that image.But I want to display camera captured image like on camscanner image using image processing, Can anyone suggest to dart library to do my task?
I have found a suitable answer for my requirement. I have used "edge_detection 1.0.5" package for detect edges for capture image so then final output will same as camscanner output.
https://pub.dev/packages/edge_detection

Display Image when beacon is detected

I'm trying to make an image appear on the screen of my app, when a beacon is detected. I have currently created a dictionary by assigning an image to each beacon using the minor value, however I'm not sure how to display the image.
{ let lookupTable = [12754: "phone-icon", 22279: " StoreLocation"]
}
Here is an image of how I want the image to appear on the screen
I need assistance of how to display the image like shown above in the attachment, when a beacon is detected.
Thanks

Unable to convert a PNG image using UIImagePNGRepresentation

I'm writing a function to download a regular PNG file from web server and save it to iPhone Photos album. I don't get any error for my code listed below but UIImagePNGRepresentation doesn't perform the convert at all. All images I got were black. I have to enable "auto-enhanced" under Photos to display those image properly. Any clue what's wrong with my code? Thanks in advance.
UIImage *orgImg = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://server.com/test.png"]]];
NSData * convertedData = UIImagePNGRepresentation(orgImg);
UIImage * img = [UIImage imageWithData: convertedData];
// Save Image to Photo Album
UIImageWriteToSavedPhotosAlbum(img, self,
#selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), nil);
Some more details of these two output images, orgImg and img:
If I pass orgImg to UIImageWriteToSavedPhotosAlbum directly, I did get the same PNG image hosted on the server. However Photos application on my iPhone displays it as a black image because Photos doesn't enhance PNG format automatically.
As for the img I got after using UIImagePNGRepresentation, the image data has been changed by the method, some meta data such as width/height have been removed from the original image. However Photos app on my iPhone still display it as an all black image.
Both images display properly if I copy them into either Safari or email. I didn't get any problem if I use JPEG in the server side either. Just curious why only PNG format doesn't work.

Getting UIImage size when Image is picked from Photo Library

In my application I am uploading the image picked from Photo library. before uploading I need to show the size of image so that user will come to know how much data he need to transfer over network.
To Achive this I need to get Image size , I tried with UIImagePNGRepresentation,after this I am getting size in terms of some MBs,but when I dump image with data received from UIImagePNGRepresentation,size is shown in some KBs. why this is happening?
Does iOS internally compress the image data? how to get image path when picking image from photo library?
Thanks,
Sagar

No thumbnail in iPhoto for images saved with UIImageWriteToSavedPhotosAlbum

My application downloads JPEG images from the web and save them to the device using UIImageWriteToSavedPhotosAlbum. All works fine except for one issue: when I browse iPhone's photo library with iPhoto, some images have no thumbnails -- an empty dashed rectangle is displayed instead. Those JPEG images application downloads are also generated by my application as a result of processing pictures either taken by device camera or picked from Photo Library. Maybe I need to do something special during image processing that will make thumbnails visible?
Try something like
UIImage * original = [UIImage imageNamed:#"sample.jpg"]; /* make image from CGRef */
NSData * imdata = UIImagePNGRepresentation ( original ); /* get PNG representation */
UIImage * png = [UIImage imageWithData:imdata]; /* wrap UIImage around PNG representation */
UIImageWriteToSavedPhotosAlbum(png,
self,
#selector(image:didFinishSavingWithError:contextInfo:),
nil);
This will convert your image to PNG, and the thumbnail will show in Photos.app.