In a gist this is what I want to do:
I want to load a 100x100 region (any part) of a 5mega pixel Image into a Android Bitmap class so that I can draw it onto a canvas element
Its that simple. Thats all I want to do. Thats it. Nothing more. Nothing less. Sounds simple enough. So before you have a smirk on your face, read on further down.
I understand that this question has been asked a million times already. And I have also done my homework, researching it. Unfortunately I have hit a dead end from all sides. Maybe I need to make my question clear enough.
There is a limit on the amount of heap the Android VM lets you allocate. So loading a large bitmap, even the one from its own camera (I own a Nexus S) is not possible by using the following function.
BitmapFactory.decodeStream(InputStream is)
Yes I could scale it by using BitmapFactory.Options, but how then should I zoom in?
Now I am trying to design an image viewer which can smoothly zoom in/out from the image. Obviously that's not possible if I can't even load the image.
In gingerbread we have a new class BitmapRegionDecoder , but I am designing my app for Froyo. All these classes have hooks into the native api which use the Skia 2D Graphics Library. The Android NDK does not give access to these api's also. Maybe there is a way to manually build Skia and use it to load a java bitmap. But I am not sure how?
It seems to have been solved already (http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/) in this app - https://market.android.com/details?id=image.viewer by using the memory allocated in the native C code using malloc/new. But I cant figure out how?
So make things clearer what I want is something that can zoom in/out of an image to full resolution. If possible it should be smooth or atleast it can be done in a separate thread.
If I need to use OpenGL, then please give me a sample code also.
I figured this out on my own. :)
Its not the best way, but it works wonderfully.
I created the bitmap in native code and accessed subset of its region using the Skia graphics library. (Which would mean that I am accessing private API's and its functionality could easily break with newer Android Versions).
http://code.google.com/p/skia/
I had to link against this lib in my C++ code and access this functionality through JNI.
Related
I'm in need of a recommendation of a free AR library that will allow me to display location indicators (2D views) on top of a camera overlay (you probably know what I mean).
So far I've tried using this iOS library, but it seems to be out of shape since I did not get good results -> somehow the views got displaced and I did not grasp the math behind it.
I'm also in need of an Android version, but that can wait, so I'd like an iOS recommendation.
I've used BeyondAR on Android a couple of times and It works:
https://github.com/BeyondAR/beyondar
You just need to have the coordinates of the object to show and the image.
I am looking for a blur algorithm for an android app. The algorithm I found here Fast Bitmap Blur For Android SDK doesn't work in an AsyncTask.
I receive data from a sensor over a long time (one until two houres). Depending on the data an image must be blurred more or less. All pure java code I found is not fast enough wherefore I want to access native C code over jni. Is there anybody could give a hint?
Thanks anko
I'm working on an Android App to show images. One of the requisites is show gigapixel images.
I found problems with memory showing normal images (>=1Mb) but i think that i have solved it.
For gigapixel images, wich is the best way to manage this files (>=15Mb) and prevent OutOfMemory errors?
Anybody had worked with this types of images?
Anytime ive ever seen anything like this done (bearing in mind this is more when Ive seen super sized textures being applied in rendering engines) the images are brought in in tiles, much like the way google maps brings things in.
Based on the zoom level different images (mipmaps) are used, each having a different level of detail, and you only load the tiles necessary. This way (depending on what you need from the application) you can get away with loading small images but keeping a very high level of detail when zoomed in.
Android has memory limitations for App, normally about 48/64MB.
I'm the author of PPV360HD, a Gigapixel Pano Viewer for Android. I've used C++, the native layer doesn't have this constraints.
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'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.