Im having problem in my code in KITKAT OS. I want to get/display an image from gallery and decode it if its a higher size and its working fine for API lower than 19. But when I tried my app in KITKAT, I always get a null pointer exception because it returned.
content://com.android.providers.media.documents/document/image:62
I already look for solutions and found this.
input = context.getContentResolver().openInputStream(selectedImage);
bmp = BitmapFactory.decodeStream(input);
Its displaying the image but I'm missing one more step, that is to decode it since i cant get the exact file path of the image.
Bitmap imgbitmap = BitmapFactory.decodeFile(filepath, options_for_not_toobig);
How would I get the exact address of the image in KITKAT or how other way in decoding an image.
thanks
Try this code if Android version is kitkat:
ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri, "r");
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor);
parcelFileDescriptor.close();
Go through this link - https://developer.android.com/guide/topics/providers/document-provider.html
I've posted a answer in another post where similar issue is lifted. There youll find the method for getting the path in KitKat.
File Upload in WebView
Related
From the IDocumentFaceRecognizer result, it returns a face image as an imagesource, but I need it as a byte array or stream. How can I get a reference to the original source, so I can save the image locally to my device?
Thanks
We already answer it on the Github, but I will post it here to keep everyone in the loop:
The original source is platform dependent and does not always exist in form of byte array. You can see how SDK creates ImageSource object on Android and on iOS. You can change the source code of these functions to adapt to your needs for the platform you are targeting.
Best regards
HELLLPPPPP!!!!! I am programming in Corona SDK, and I am trying to insert a backround image, with the following code ---local backround = display.newImage("bluebackround.jpg")--- But it does not want to show up in the simulator. It keeps giving me the following message in the output, ---Failed to find image 'bluebackround.jpg'---. My image is saved in the project folder. I am using Microsoft Windows software. I have done another project using Corona, and I inserted images completely fine. Anyone know what's going on with my code and how to fix it? Thank you very much in advance.
_W = display.contentWidth;
_H = display.contentHeight;
local image = display.newImageRect(--[["Name", width, heigth]] "bluebackround.jpg",_W, _H)
image.x = _W/2;
image.y = _H/2;
The your image need to be in the same folder as main.lua in your case. On the same level. Moreover, I think you misspell name of your image. You write 'bluebackround' without letter g in middle. So check name of the file.
From Corona documentation
Image guildelines:
Corona supports PNG and JPG format,
Images should not contain an embedded ICC profile,
Avoid progressive JPG files since they will take much longer to load.
Dear fellow community!
Does anyone know how to get the photo files in original size from Instagram? They surely store original files in full size, since you can upload a photo via app to your IG profile, delete it from the phone, and it still syncs your IG with phone library to get this photo back in full resolution.
Their API supports fetching up to 1080x1080px, plus I found this method via Chrome developer tools: http://www.dailydot.com/debug/instagram-high-quality-photos-download-google-chrome/. Script that could do it doesn't seem reliable on large scale, so I'm still looking for a automated better solution.
Please share any experience that could help.
Try to change 640 to 1080 and remove sharpness like in my example:
str_replace(array("s640x640","sh0.08/"),array( "s1080x1080",""),$img['standard_resolution']['url']);
all photos on instagram have real image url (except profile picture image), you just need get access instagram api, decode json result then get real url image.
you can see my example code for search tag using instagram api : http://pastebin.com/fMu7w808
Sorry to say, but the code on the pastebin will not work correctly for this purpose. Standard_resolution does not display the representation for original size of posted media.
$url = $datas->images->standard_resolution->url;
Will yield the following result, while the original image that was uploaded is 1080px wide. (Following is an example, not a working link)
"standard_resolution": {
"url": "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/14613148_236279861425099_8741797152912868864_n.jpg?ig_cache_key=MTX3ODU5Mjg5NDY4NDEEN3E0CA%3D%3D.2",
"width": 640,
"height": 334
}
The trick is to replace the s640x640 part in the url, thus adding the next line in order to get the url of the picture as it was uploaded :
$url=str_replace("s640x640/","",$url);
I have a card game program that when a card gets discarded and is found to be a certain type of card, it goes into my DefeatedChars pile, which is just a PictureBox named DefeatedChars. Currently all my images are loaded during runtime using ImageLocation which is the string of some website that stores all the card images. I want to know how to load this string to the PictureBox's Image property so I can rotate it because trying to rotate gives me a null pointer exception because Image is nothing, at least I think that's why. I do know through debugging that when DefeatedChars.Image is nothing. My question is, is there a way to rotate the ImageLocation after it's been loaded or is there a way to move the image found at the ImageLocation into the image property. Ultimately, when I'm done with the game, I want the image found at the image location to be stored somewhere locally so that if the website changes, which it does, the cards will retain their images and properties, but that's a question for later down the road. Here is the code I am stuck at that gives me a null pointer exception. I'm coding in Visual Studio.
DefeatedChars.ImageLocation = tempCard.ImageLocation
DefeatedChars.Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
I tried this...
DefeatedChars.Image = Image.FromFile(tempCard.ImageLocation)
But I ran into a "URI formats are not supported error". Then I found this little gem on the internet, which replaces the first line of code above.
DefeatedChars.Image = Image.FromStream(System.Net.HttpWebRequest.Create(tempCard.ImageLocation).GetResponse().GetResponseStream())
It turns the URL into a stream so it can be used by the Image property and it works like a charm.
I am displaying an image in figure window in MATLAB using following code.
im = imread('Image02.tif');
processAndDisplayImage(im);
hImage = image(im);
set(hImage,'ButtonDownFcn',#clickInImage);
But problem is that the third line above makes the image changed for some reason I don't know. Is there any way to get image handle without the modification?
UPDATE: Resolved the problem. Please refer to my answer below.
The image graphical command cannot change the image. I can only guess that it shows the image in a way you don't want it. Inspect the range of the image -
max(im(:));
and also the type:
class(im);
and try to figure out what is wrong
Perhaps you could modify processAndDisplayImage so that it returns a handle to the displayed image as an output variable?
Instead of
hImage = image(im);
I used following to solve my problem.
[hImage hfig ha] = imhandles(gcf);
But I still don't understand image command does to the actual image displayed on figure.