I'm trying to emulate something that is working in an app called InstaWeather. They have numerous overlays that you can switch through, that merge with the picture you take to produce a custom weather image that you can share.
It doesn't seem like these are canvas drawn on, and I can never get anywhere near as clear and high res drawing things on via canvas. Does anyone have any idea how the overlay and taken camera image are merged? Bearing in mind the overlays are based on the current weather data so aren't pre-existing.
I'm not sure if this will be regarded as too general, but I do have a specific issue in that the images I create often suffer hugely from being drawn on via canvas.
Related
I am working on a text RPG game for Android, and would like to create some kind of an area map for the player's reference. I Googled it but was directed to Tiled. I am not trying to create a playable level map, just a basic map that the player can open to see areas explored so far for easier navigation. I would probably create these graphics myself using Fireworks.
The problem is a phone screen is only so big, and I need to somehow allow the player to swipe left/right/up/down to see all parts of the map. I guess on the biggest tablets perhaps the whole map would fit, but I need to support smaller resolutions as well.
So basically I think I need a way to display the map image in an activity (which I know how to do, duh), and allow the user to scroll around it because it will be way bigger than the screen.
I am developing an android camera app. The camera pictures are later processed by OCR, so the picture must be as sharp as possible.
If you shake the camera, it looks as if the digital camera overlays multiple images, to create the effect of motion blur:
Example 1: http://i.stack.imgur.com/nqrmd.jpg
Example 2: http://i.stack.imgur.com/ZBx6F.jpg
If you examine the pictures closely, the motion blur looks to consist of 2 or 3 images taken in quick succession and blended together to simulate light exposure. I understand that this amounts to the way digital cameras work.
But I'd prefer having a single crisp image rather than a properly exposed one. The app can use histogram corrections to make the text readable again for OCR. The image does not have to appeal to the human eye.
Is there a way to better control the camera to get these sort of raw image snapshots?
I had some limited success using the "Action" scene mode on the camera. Not much, but it's as far as you can get.
I'm relatively new to Android development, and I'm currently developing an app that requires a pinch-zoomable and pannable image that will have other images overlaid on top of it, similar to a MapView but without using the Google Maps API.
I've done a bit of looking and found that I may be able to accomplish the overlay portion by doing the method in this question: Draw images on top of each other in android
However, I don't know if that would make the ability of doing a pinch-zoom and/or panning a large image feasible. Would it be worth it to create a GLSurfaceView and just implementing the needed functionality, or is that overkill because I'd be reinventing the wheel?
For what it's worth, the large map image itself will be fetched from a server (but if needed it can be split into smaller square regions), and the icon that will be overlaid at various positions on the map will be embedded in the app itself.
Sony Ericsson made an excellent PinchZoomable ImageView class. I modified it for my needs. I merged their pinch zoom and single-point touch zoom (for phones that didn't have multitouch) http://code.google.com/p/motivatormaker-android/source/browse/MakeMotivator/src/com/sonyericsson/zoom/ImageZoomView.java
Their tutorial is here: http://developer.sonymobile.com/2011/04/12/how-to-take-advantage-of-the-pinch-to-zoom-feature-in-your-xperia-10-apps-part-2/
I got pretty good performance out of using these classes without needing to use OpenGL.
Is there a way I could show what the hind-side camera captures on a full-screen such that it creates an illusion of screen being see-through? It doesn't need to be perfect, just convincing enough, a little lag won't make any difference.
Is it possible to create such an effect using phone camera? If yes, how can the effect be achieved? (as in what transformations to apply etc.)
(I already know how to create a simple Camera Preview)
Edit : Now, I also know it has been done, http://gizmodo.com/5587749/the-samsung-galaxy-s-goes-see+through, But, I still have no clue how to properly do this, I know trial and error is one way, other is calculating what part a user should be seeing if phone wasn't there.
I think there would be some factors involved like -
viewing distance,
viewing angle,
camera zoom range,
camera focus,
camera quality,
phone orientation,
camera position (where is camera located on phone) etc.
So, I don't feel this problem has a simple enough solution, if it is not so, please clarify with an answer.
Thanks for help,
Shobhit,
You can use standard 3D projection math to project a portion of the backside camera image onto the display; you can manage this by assuming everything the camera sees is at a particular depth from the backside camera, and by assuming a particular viewpoint for the observer
You can improve on this by looking for faces/eyes using the frontside camera. You can get a rough estimate of the the viewing distance from the eye spacing, and assume a viewer position midway between the eyes. Of course, this only works for one viewer at a time (e.g., if your face tracker finds multiple faces, you can select one of them).
Also, you can improve the illusion by calibrating the camera and screen so you can match the color and brightness from one to the other.
In my application I need to draw a large network (basically, little boxes connected with lines) and the user will be able to zoom and pan it around.
My first option was to draw the network directly to the canvas, but I thought that was not very efficient, because each time a pan event occurs, the drawing process begins again.
So I tried to use a large mutable bitmap and draw my entire network only once (or at least whenever zoom occurs), and blit the necessary areas to the canvas.
My problem is, since the network is rather big, I get OOM exception when creating the bitmap…
What should I do? Draw directly to the canvas? Use several smaller bitmaps?
Thanks,
Direz
My first question to you is how many sprites you have going at once? By far, the fastest mechanism for having many sprites on the screen is to use OpenGL due to the hardware accelleration. The besy way, on Android, I have found to do this is to use the Cocos2d android (not to be confused with the ios version) which is available on Google Projects. You will have to use the IOS documentation in order to understand it though and there are a few decent tutorials to get started with online..in particular, the hello world template here... Www.sketchydroide.com/Blog/p?=8. It is out of date compared to the latest IOS cocos2d but thats to be expected. I have found that the programs run MUCH faster when not connected to an active debugger session in my experiments.
If you want to stick with your current approach or the above is still not fast enough, you are going to have to attempt to cull any drawing which does not appear n the screen meaning a general function of the form "if the sprite's x and y values are outside the bounds of the visible area, dont draw it" which is basically how most tile base games handle the issue.
It sounds like you are doing the drawing manually if you are doing little squares. I think it is more adviseable to go ahead and draw on the canvas but to be very careful about managing your sprite counts and to avoid heavy for loop iteratiins that occur on
the frame update loops where possible. It is rather easy to max out your little handset with drawing operations.
Another option might be to draw the entire bitmap once into memory and then use a copy rectangle operation to transfer the image to the screen without drawing the full bitmap you have created. I think that copy rect should be a fast operation normally but if you are using it to draw the whole screen it seems like overkill and probably wont work as well.
You're probably not going to like this, but if all you're doing is drawing boxes and lines, the efficiency of the canvas is going to be pretty dang high. Are you getting UI lag or something?
One thing I have messed around with is drawing collections of subcomponents that won't change much or at all to a bitmap then rendering (scaling/moving aren't all that expensive if done at the right level) to the canvas can help efficiency. I have tried in the past to create a framework for rendering a tile-like subset of an existing larger image, but did not meet much success. I've made things work, but the code just gets ugly.
Oh, also a quick test to see if the component you are rendering is within the rectangle created by the screen can save you a bunch of processor time.