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
Related
I have an application that gets image (from gallery or camera) and then I open this image in some Activity. Then I want to draw shapes on this image on tap, these shapes (once drawn) can also be dragged around over the image and removed. After drawing user can save this image with shapes so it can access them later from the application at any time.
I have managed to make image import form gallery or camera to my activity.
My question is I just want a summary of how would this need to be constructed in order to work? How would I save images with shapes and their positions so they are accessible later? I would also have an activity (I guess?) in my app which would show thumbnails of all images edited so far. I have attached some images for reference (first image is image edit screen, second image is showing thumbnails edited for far, each can be accessible for edit again).
I am a beginner so please bear in mind.
I am trying to make an Android aplication, in which you take a foto. You zoom in to a desired region of the foto then you copy this region into a Bitmap for further processing.
I tried to make a new mutable Bitmap to copy the Bitmap from ImageView object that holds the picture but I receive out of memory error.
Another problem is how do I copy only the desired region?
I have the impresion that if you copy one by one each pixel you copy the whole picture.
I am using Android 2.2.1 API level 7.
I need only some tips to search for, till now the search of Bitmap documentation was unsuccesfull.
Thank you in advance.
I copied the data hidden in the cache:
mImageView1.setDrawingCacheEnabled(true);
mImageView1.buildDrawingCache();
mImageView1.getDrawingCache();//this is the data I need it.
I'm creating somekind of 2D image editor in Android and I have the big problem of big files don't fit in memory.
I need to zoom in/out the image put some shapes and then save it.
My question is:
How can I load the image and save it without getting out of memory?
I've been reading about bitmapregiondecode and the sample technic but there's must be another solution. How can I save the image if I always use regiondecode?
The images need good detail quality because it's architectural images... and the lines must be well defined.
I'm new to this, help me please.
Note two things while dealing with images:
tempBitmap = Bitmap.createBitmap(bit);
clone the bitmap which you are using for zoom and other operations but wont use the original because it looses its clarity when you save;
when done with bitmap give
bit.recycle();
to release the memory space
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.
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).