I am making an android app that uses the inbuilt camera in the tablet/phone. I need help with making the picture I just took “editable”. The idéa is that the user can draw things on the pictures, like you do in paint and then be able to save the picture with these drawings on it.
What do I need to do to make this possible?
The backbone for the code is #38-#41 from: http://thenewboston.org/list.php?cat=6
My main class looks like this: http://pastebin.com/FH0J7u1A and I have a button and an imageview in my layout xml file. When I press the button the camera launches and I can save a picture that is then saved in the imageviewer.
This is a very vague question, but I understand because I wondered the same things six months ago. Sadly, vague questions get vague answers, and the bottom line is that no one person on SO is going to write this code for you. You have a lot of research to do yourself. Here’s a basic description of how I would get started.
First look into tying the app in with the camera. This is pretty easy, there’s an intent you can call and onActivityResult you can receive the path to the file of the image they took.
The layout of your edit activity to edit the picture will have to have a Canvas object, and you’ll probably need some buttons underneath or above it for them to pick their drawing tool.
The Canvas of the layout has to be implemented in a separate class, and it needs to implement runnable. This requires you making a
run()function in the Canvas class, and inside of that you’ll have a loop. Through each iteration of that loop, you’ll clear the canvas, draw the picture usingdrawBitmap()to fill the screen, and then draw everything that the user has drawn.Now, in the edit activity you’ll have to implement a touch listener. This will require you making a
onTouch()method that will give you aMotionEventtelling you where and how the touch occurred. Each time the screen is touched you’ll want to look at the tools they currently have selected, and add it to the drawing that is painted on the Canvas.When they’re done, save the result of the Canvas. I am not saying that this is the best way to create the app that you have in mind, and I am by no means an expert. This is just a suggestion of where I would start thinking as a beginner.
Like I said, you have a lot to learn! I recommend searching for any terms you don’t understand or widgets you haven’t heard of that I mentioned, and looking at tutorials related to them. Somebody mentioned newboston and they’re right, he has good tutorials. I also recommend some books from Apress, particularly I’ve referred heavily to “Beginning Android Games” for anything involving Canvas interaction.