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.
Related
I need to make a map with thousands (~1500) Markers on it. Each marker has a unique Bitmap, as the icon has text below it to show some information (which may be unique).
Unfortunately, the app crashes due to memory problems when loading so many different Bitmaps.
Clustering is not an option.
Also rendering only markers which are visible in the viewport does not work, as it needs to much CPU to handle so many elements.
I am already using an LRU Cache for caching Bitmaps which are the same.
Is there any advice you can give me to achieve my goal?Thanks!!
This is mainly a question for someone who has adequate experience with mobile development in both android and ios, and knows about mobile application optimizations and performance, so please refrain from answering generic solutions like "choose what you like or what suits your preference etc".
So, I am developing a mobile app for ios and android in phonegap, and it has graphics for almost all possible social medias like facebook, twitter, snapchat. My questions is whether I should maintain the icons/graphics for each media as individual files, or as a combined sprite image.
I understand on web sprites are the best options, but since these graphics are embedded in the app, it should not be a problem for the mobile app. Only thing I am concerned about is how the number of embedded images and icons in the app will affect the performance of the app.
I prefer to keep each social media icon in separate file because it is used at various places in the app with different styles and sizes, so using a sprite in that place would mean taking care of background size, image width all individually, whereas with the individual icons it is very straight forward. Also makes it easy to add/change medias to the app without modifying existing graphics.
So if someone can please tell me what effect will it have on keeping individual icons and graphics within the phonegap app instead of sprites and whether it is the better option or not!
i have worked with a android for over two years and i have realized that pngs are the best format to work with in android application and for JPEGs the best practise is to use a hyphen to name the JPEGs eg image_one.jpeg
Using png's will be the best format as they have never failed.I would gladly help if u need more assistance
I am trying to list some items in a way very similar to Play Store, currently I am using a Webview and managed to do something similar looking, but performance wise it is very slow.
I'm wondering if Play Store also uses a Webview and gets data from a mobile website like I did, or Play Store uses some sort of widget/view/component to achieve this task, possibly natively. It seems on slow or zero internet connection, the application frames+names are still displayed, and only the images do a lazy load, possibly contributing to much smoother application performance while still capable of listing lots of apps on scrooldown. Here is the Play Store page I'm trying to emulate on my application:
There is a video that explains the theory behind the new Google Play design. No code though. But it is very interesting.
Basically they are using Cards as their main building blocks.
Cards are organized into clusters.
And everythings rests on top of a Canvas.
You can check out the presentation slides here.
Easiest to implement this kind of screen with a GridView Tutorials for using it (there are tons of others too):
http://www.mkyong.com/android/android-gridview-example/
http://www.androidhive.info/2012/02/android-gridview-layout-tutorial/
There is also a GridLayout in Android. The difference between the two components is explained clearly in this post: GridView VS GridLayout in Android Apps
Currently I have all of my sprites as individual images, 186 bitmaps in all but not all of them are used in each level. So, when a level is loading, only the sprites needed for that level are loaded into a hashmap (typically about 40-80). When scrolling over my tilemap, I simply reference these bitmaps in the hashmap to draw on the canvas
Initially this seemed like the simplest approach so it's what I went with. That said, is there any reason to consider using sprite sheets instead? If so, what would the advantages be? Using sprite sheets seems to be very popular from what I have gathered on the internet, but i'm not sure why, or why it would be better than what I am currently doing.
Thanks for any thoughts
The sprite sheet is used when you need to pack many small images into one file for to increase the speed of sending them through web. If you do not have problems with sending many small thingies, use it as you do - it is much more effective model for use.
Why they are in fashion? Because all web techs are in fashion. (a little exagerrating here :-)
If we'll look into the problem deeper, much depends on how do you realize that image map, where do you place them into (DB or files), how often to you reload them and many other details that could easily reverse the results of comparison. If you need really so deep research, simply do the comparative testing.
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.