I've searched the forums for solutions to the "out of memory" problems when dealing with large bitmaps and I seen as many solutions as there are questions.
Let's say I wish to create a game board with squares like a chess board that will have sprites moving on the board and I wish to be able to zoom in and out. For this example let's make the board squares 100dip x 100dip. For a chess sized board that's 800*800*4 or roughly 2.6MB for the entire bitmap. Since each square of the board could have a different background image, redrawing the entire board every single frame is too CPU intensive even on a real device.
I've written similar things in .NET, and to do so I would make two bitmaps, a static "board" bitmap (whch is updated infrequently as the background "square" changes) and a secondary "sprite" bitmap that overlays the board, both of which are drawn at 100% and then scaled to zoom-factor when drawn onto a 3rd "surface" bitmap that is the one being rendered to the user.
Taking this same approach with B4A, when testing on an AVD I generally get an out-of-memory error when I attempt to InitializeMuteable on the 2nd bitmap, let alone a 3rd.
What is the best way (or even a way) to present a large bitmap with animated sprites to the user, while still allowing them to scroll/zoom the final image? Or do I have to settle for one or the other?
Any and all suggestions are welcome
Thanks,
- Richard
Let's say I wish to create a game board with squares like a chess board that will have sprites moving on the board and I wish to be able to zoom in and out. For this example let's make the board squares 100dip x 100dip. For a chess sized board that's 800*800*4 or roughly 2.6MB for the entire bitmap. Since each square of the board could have a different background image, redrawing the entire board every single frame is too CPU intensive even on a real device.
I've written similar things in .NET, and to do so I would make two bitmaps, a static "board" bitmap (whch is updated infrequently as the background "square" changes) and a secondary "sprite" bitmap that overlays the board, both of which are drawn at 100% and then scaled to zoom-factor when drawn onto a 3rd "surface" bitmap that is the one being rendered to the user.
Taking this same approach with B4A, when testing on an AVD I generally get an out-of-memory error when I attempt to InitializeMuteable on the 2nd bitmap, let alone a 3rd.
What is the best way (or even a way) to present a large bitmap with animated sprites to the user, while still allowing them to scroll/zoom the final image? Or do I have to settle for one or the other?
Any and all suggestions are welcome
Thanks,
- Richard