How to take an image from gallery - android

I need to pick an image from the gallery of the phone in order to do some stuff with that.
For this purpose I tried to follow what is inside this android pick images from gallery thread but I think it's too old, probably I need to use the intent anyway but I don't understand how and how to pass the image picked to a bitmap variable.
Precisely I need to take an image and then convert it to bitmap and do other stuff (ml algorithms).
Thanks.

Related

How to crop image with known path based on user selection

in my app I capture a photo using intent MediaStore.ACTION_IMAGE_CAPTURE and I save image into external storage that is private to my app. I also save the path to taken picture.
In next step I would like to crop 3 pictures from this photo but I cannot figure out how to do it. I found this article Crop an Image by passing the image file path in Android but the answer uses com.android.camera.action.CROP, which is often not supported. I would like to crop it like this
Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.xyz);
resizedbitmap1=Bitmap.createBitmap(bmp, 0,0,yourwidth, yourheight);
but I need to crop picture according to user selection. Can anyone help me with this? I am pretty stuck here.
So I ended up using some third party library for cropping pictures. I recommend you to do the same. You will find plenty of them on github, choose according to your preferences.

Crop and Save image android

i am doing an android app that launches camera and capture an image, then crop and save the image. Then takes the image for some process.
i was trying with some suggestions and tutorials by searching on Google. but i am getting error after cropping. The image is being cropped and actual image remains in SD-Card also the cropped image saved as "image~2" in same location. but while we try to use the cropped image filenotfoundException is returned. Any one please help me.
"can i post my code?" - You should, actually, if you want some help here... Anyway considering the exception, you're searching for the image where it is not.
Or you can try this: https://github.com/edmodo/cropper

How to put other images on a photo Android

I take a photo in my Android app.
I want to put other images in that photo to create effects
like a ballon of conversation, a legend, and others.
After that I want to save this Image in another Bitmap.
I try put my photo as a background image, and put another ImageViews components under that and try to take a printScreen of my screen. But I think it isn't the best way to do what I Want.
Can anybody help me?
Sorry for my english
I think the best bet would be create a Canvas based on your photo (you'll need it as a mutable Bitmap) and then use the drawBitmap() to draw another bitmap onto yours (you'll have to pass it the offset and Xfer mode).
The original mutable bitmap will now contain the combination of of your images
You can try FrameLayout.
Just put the photo in the background, and then put ballon of conversation in front of photo.
If you want to combine photo and ballon effect, you could use Bitmap.
Just record the effect's coordinate.

Drawing on Canvas with an image on background and save image

I want to open an image from SD card, while image is on display I want to draw on it using touch and motion events and save the image back. Any help or pointer to any sample code would be of great help.
I'm sure there are many ways, and many ways better than this but this is how I would do it:
Basically in my understanding you need to open the image from an SD card to a bitmap to a imageview in your activity. http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/2/
Then you need to go pixel by pixel and get each value for the color so you can change it in an onTouchEvent. http://developer.android.com/reference/android/graphics/Bitmap.html See getPixel() and setPixel()
The user gets to draw stuff on it. You need some way to capture the motion event, and change your data model of the image you just got by getting all of the pixels. You could use a surfaceview or something similar. Android: creating a Bitmap with SurfaceView content
Finally you need to save the picture to the SD card. Android write to sd card folder
Hopefully this helped

how to display images from a selected folder in the form of a slideshow

I am using the following code to pick a folder from the SDCard.
Environment.getExternalStorageDirectory();
After selecting the folder, I return the path of the folder and display it in a text view currently.
What I want to do is, I want to display all images in the selected folder in the form of a slide show. How do I go about in doing this?
1. convert images in the Bitmap.
Bitmap bm = BitmapFactory.decodeFile(String pathName);
Decode a file path into a bitmap.BitmapFactory
2. Using ImageView set that Bitmap in ImageView.
ImageView.setImageBitmap(Bitmap bm);
Sets a Bitmap as the content of this ImageView.
3. For slide show just after some delay (use timer) after change the bitmap of ImageView.
We are appreciate If you are do by yourself. Without finding any code.
EDIT: Here Mihai Fonoage's Blog Displaying Images from SD Card In Android - Part 2 It display images from sdcard in Gridview. You can modified it and display Images one-by-one as a slideshow.
If all you want to do is cycle through the images one by one, there are numerous options. You could for example simply use a Timer (or preferably a ScheduledThreadPoolExecutor if you're writing production code) with a fixed interval or have a Handler repeatedly post itself with a certain delay. With each 'tick' you can then simply set the next image.
If you're after something a little more fancy, it may be worth looking at implementing an ImageSwitcher, which provides the ability to also show thumbs of upcoming/previous images. Code examples are wide spread, e.g. here (scroll down a bit).

Categories

Resources