I'm new to Android and Java programming and I've manage to create a simple paint program, but how do I add a zoom feature? Right now I'm just extending the View class and using the "onDraw()" method.
Do I have to use a Drawable to be able to add zooming functionality? I'm not really understanding the differences between the two.
If I am way off base then please point me to a good tutorial on paint/zooming.
I think your question is beyond the scope that stackoverflow Q/A format can provide. I know you're asking for 'simple' but imho that's probably due to your lack of perception about the scope of the question that you're asking.
In order to support zooming you need to know what kind of image processing engine you want. Are you creating a vector or raster based drawing program? If you do not understand the difference between the two then you'll going to have a difficult time figuring out what to do.
You should probably at least gain a basic understanding about these various topics (links to books pulled more or less from the top of amazon's search results):
Image Processing
Computer Graphics Fundamentals, two, and three
SVG (vector graphic format)
Wikipedia links:
Vector Graphics
Raster Graphics
Image Processing
Open source image processing apps (not android but source code never hurts to see how others have done something)
Paint.net
GIMP
Inkscape
I'm sorry there isn't an easy and direct answer to your question. I'm also not saying that you need to become an expert in these topics to do what you want. You just need to familiarize yourself with them and then you'll probably be able to implement what you want without much difficulty.
Related
I am trying to find approaches on stamping multiple textures on an object (3D .obj) Android. But, I am unable to do so, I have tried min3d but not sure if it is the right way to do it?
Is there anything available around which is similar to this? Or How Should I approach this UI? Below is the UI of model and how I want to stamp an "image"/texture on it, in addition I want to change the color of the model / add text on it.
In addition, I am planning to give touches on it, by stamping username/label/textview at the back of the model by using rotation through touches.
Please guide, which SDK should I use on Android, what is the best approach to do it.
What you want is basically just rendering textures on a given 3D mesh, as far as I can see. You could take multiple approaches for this: The simplest being just texturing the actual object, but a more complicated approach could involve rendering the object and "stamp"&text textures separately, giving the illusion of being overlayed (Not preferable though, as this will be difficult to manage correctly).
For texturing, you can either attempt rendering different textures after each other (First the background, then the stamp, then the text), or combining the different elements into one texture (pre-processing) before rendering.
I recommend having a look at the following posts and articles:
OpenGL ES (which can do everything you want to do, but has a decently steep learning curve)
Switch to a different 3D rendering engine if you find it too difficult to use your current one (Many options, although most are fullblown game engines)
Loading 3D objects and textures for OpenGL ES rendering
Check out the following git snippets and articles on texturing in min3d: this, this article, this article on object loading
You did not provide any code displaying your current attempts, so it is difficult to say what exactly your problem is, and how to solve it. If you edit your question you might receive more concrete solutions besides just links to potentially helpful resources.
Perhaps working with the OpenGL ES 2.0 api might be an option. Take a look this repo here called the Android 3D Model Viewer which makes use of it, it might help you out.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Hello everyone and thanks for your time.
Introduction to the problem: Basically the main problem is that I'm designing an android tablet application and I don't know exactly which is the best way to implement the kind of design I've been thinking about. I've been reading that is possible to use another platforms apart of Android, like OpenGL or HTML, but I don't actually know how to do it and if its necessary.
What do I attempt to do? I didn't know how to explain exactly which is my idea using words so I decided to prepare a small image about it, here it is:
So, the idea is to drag&drop the buttons to the color square, and detect if they are colliding, if that happens, start an event. Then all the buttons are going to be ordered again by themselves.
Which is the question then? I'm new at android, and I have no idea which is the best way to start implementing this, if I should bet for OpenGL or program directly in android. And in both cases, which is the best way START CREATING something like this?
Last things: I want to make clear something, just in case: This IS NOT any school work that someone asked me to do, I'm doing it by my own. I'm NOT ASKING PEOPLE TO DO MY WORK I'm just asking your opinion and asking for help and guidance about how to start managing this. (so I want your professional opinion, not any single line of code) :D
Thank you very much to you all. :)
MartÃ.
This sounds like it'd be pretty easy to do in HTML / JavaScript using touch events, maybe using a support library for drag/drop events. I don't know if it matters to you, but the nice thing with that solution is that it'd port pretty easily from Android to other mobile devices.
Like Quintin said, if performance is a big concern you can optimize and go to OpenGL, but you can probably knock out a simple prototype in HTML in under a day...
in my opinion you don't need any framework. You can do it all with android. I would also advise you to use android. I'm not a good designer, but my suggestion would be for this:
2x Framelayout, for the color tools on the left side and one for the rightside
For the color tools, for each 2 colors you can use LinearLayout. And if you want the exact backgraund design, you can design it with an image software and can set it in the background.
for the colors, you can use an imageButton.
And i also advice you to read the tutorials how to design apps, here is a good tutorial: http://mobile.tutsplus.com/tutorials/android/android-layout/
Open GL seems to be your best bet here. I haven't had much experience with Android OpenGL, but it is going to be the most efficient way to write the app - since you are dealing with collision detection and colours.
Android OpenGL will be the best option since it will be natively compiled by the ADK whereas HTML is going to be interpreted at runtime.
As far as using normal bland Android layouts, I would not recommend that, since this is not a "standard" UI using the standard components. You are creating an entirely unique interface that is very graphical, and so I would recommend sticking to that.
EDIT: You will find that by using standard layouts that ALL of your user interface components will have to be customized, and you will spend a lot of time in your onDraw() methods with the collision detection.
One problem with this is that you need to check whether the object collides with another object, making certain types of objects aware of each other, and may run the risk of circular references. Whereas if you use OpenGL, you can have one list of "Shape" types and then have a "checkCollision(Shape draggedObject)" method which iterates through the list of shapes and checks the collision using an optimized collision detection for the simplest object.
The second problem is doing collision detection in the onDraw() method will make your app lag and seem sticky to the user while performing a drag. The more components the more problems.
EDIT 2:
Here are some resources for Android OpenGL:
http://developer.android.com/guide/topics/graphics/opengl.html
http://www.learnopengles.com/android-lesson-one-getting-started/
2D example with OpenGL
I'm trying my hand at making a platform game and have been thinking about what I would use to design levels.
I was thinking of using a tile palette that would contain the graphic tiles and their properties. And a similar palette that would contain sprites.
This way I could drag and drop tiles/sprites onto a grid and specify property values. This could all be saved to some kind of file that would be read by the game.
Without getting too into the details, is this a sound overall strategy? Is there anything major that I'm forgetting? Or perhaps there's a better method?
This is a rather open-ended question, but I don't think there is anything wrong with your approach. You might have to try a few things to find out what works for you.
When I make platform games I find it useful to be able to edit levels while I'm playing them, by adding in code to the game which allows me to select a graphic tile from a palette and paint it onto the screen. The behaviour is usually linked to the graphic for my games but you could paint behaviour as well. You then need code for your game to save levels as well as load them. Obviously, you would probably want to remove the editor before releasing the game.
I don't know how much experience you have with game dev, but if you're thinking about making a tile-based platform game then your best bet is leveraging existing libraries/tools to avoid "re-inventing the wheel". I highly suggest looking into open source libraries/tools because you can modify them to your liking. I've had some good experience with libgdx and AndEngine in which case both have TMX support which is a file format that can be used in conjunction with Tiled map editor. I personally like libgdx because it has javadoc and very actively developed, and also that it's a framework rather than engine which gives you more flexibility (although more coding in some aspects).
I am an android development beginner with some experience in other object oriented languages like java, python, c#. So I have created various games before in Java, using buffers and graphics to draw lines and stuff. How do I do that stuff in android? I looked at some online guides, and they all seem to create a class to extend a View object, and the class will overrule the onDraw method, where they can cause the Canvas or something to draw a line.
But what if you want to draw a line based on user input? That method wouldn't work then would it?
For example, what is the simplest code for which I could draw a circle where the user touches the screen?
Also, i was wondering what books people would reccomend for beginners, especially one that includes stuff on graphics? I user the developer site for android, but I feel a book would also help a lot to understand android? Any suggestoins?
Thank you for your time, I greatly appreciate it!
There you go, this book is definitely what you need to read: http://www.amazon.com/Pro-Android-Media-Developing-Smartphones/dp/1430232676
what is the simplest code for which I could draw a circle where the user touches the screen?
Either use SurfaceView to draw or create a custom View handling onDraw() and onTouch()
Here is a suggestion ... load the API Demos app into Eclipse and explore the Graphics demo source code. There are a large number of graphics demos.
To load the API Demos app, in Eclipse click File > New > Other > Android Sample Project.
Then select your build target such as Android 4.2.
Then from the list of sample apps select the API Demos app.
And finally click Finish.
There are over 300 demos in the app, so it can be difficult to navigate. You want to look in the Graphics section.
"Android 2D Graphics with Canvas API" by Yevgen Karpenko is pretty good for beginners.
It explains basic concepts like coordinate systems and transformations, shows how to work with text and use different graphics primitives (lines, paths, circles, etc.). It also shows how to use multiple threads in graphics apps.
Below is the link for eBook version on Amazon.
http://www.amazon.com/Android-Graphics-Canvas-API-ebook/dp/B00DKIAVK8/ref=sr_1_8?s=books&ie=UTF8&qid=1374420538&sr=1-8&keywords=android+2d
I'd like to make an Android app that lets a user apply cool effects to photos taken with the camera. There are already a few out there, I know, but I'd like to try my own hand at one.
I have been googling and stack-overflowing, but so far I've mostly found some references to published papers or books. I am ordering this one from Amazon presently - Digital Image Processing: An Algorithmic Introduction using Java
After some reading, I think I have a basic understanding of manipulating the RGB values for all the pixels in the image. My main question is how do I come up with a transformation that produces cool effects?
By cool effects I mean some like those in these iPhone apps:
ToyCamera
Polarize
I already have quite a bit of experience with Java, and I've made my first app for android already. Any ideas? Thanks in advance.
There are specific classes to do this for you!
Take a look here for grayscale image processing
Here is something in C# which is similar enough to java that you should get the idea.
If you want to do something unique you might have to experiment with the tweaking of the RGB ratios yourself.