Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
Robin van Emden

Blitmask, Memory and the iPad

Recommended Posts

I have been using the flashBums Bitmapscroller on some projects, as in http://gotoandlearn.com/play.php?id=143. This works for any amount of images you'd like to scroll on your iPad.


Since I really like the elegance of your BlitMask solution, I have used that instead of the Bitmapscroller in my latest project. Yet if I try to run an app build using the BlitMask technique it will crash if I use more than about 14 images.


One way to avoid might have been to only display a subset of images. But then I'd have to do a blitMask.update(null, true) after setting images to visible=true and visible=false. That takes way too much processing time, resulting in major stuttering.


The difference seems to be in the Bitmapscroller not having to add the images to the stage, it loads them into memory (using canvas.copyPixels(photos, new Rectangle(0,0,1,1), zp)) and then blits them to a 768x1024 canvas. The BlitMask solution seems to necessitate adding a DisplayObject containing all images to the stage, thereby crashing iOS apps if the DisplayObject containing the images becomes too large. I tried adding the BlitMask itself to the stage & then do a scrollX, but that will only work after adding the aforementioned DisplayObject containing all images.


Still, maybe I am missing something. Is there any way to use a BlitMask with a large amount of images on iOS?

Link to comment
Share on other sites

Great question. I never intended BlitMask to replace BitmapScroller - they are different tools that use similar techniques but different APIs and have different capabilities. Of course there is some overlap. I suspect that the problem you're running into doesn't have much to do with adding the images to the display list, but rather the fact that BitmapScroller requires you to pass in Bitmaps yourself whereas BlitMask automatically creates them for you based on your DisplayObject(s) that are in the display list. So technically BlitMask makes its own copy internally (which requires more memory). However, there are distinct advantages of doing it this way. I'll attempt to summarize here:


    [*:1cpmvyz3]BlitMask can accommodate interactive objects (well, any DisplayObject), not just Bitmaps
    [*:1cpmvyz3]BlitMask can accommodate scaled and/or rotated objects
    [*:1cpmvyz3]BlitMask can accommodate the target's filters and colorTransforms (like tint, alpha, etc.)
    [*:1cpmvyz3]BlitMask offers a smoothing option that accommodates sub-pixel rendering (it doesn't force things to land on whole pixels)
    [*:1cpmvyz3]BitmapScroller doesn't need to capture the Bitmaps itself (you must provide them), so it uses less memory than BlitMask.


So again, I don't mean to imply that BlitMask is better than BitmapScroller - in some cases BitmapScroller might be a better fit for your needs. Hopefully my description above will help you understand some of the differences and make an informed decision.

Link to comment
Share on other sites

Thank you for your succinct answer!

Because of the advantages of BlitMask, I would still prefer to use BlitMask though - if only it would support an easy way to smoothly add more Blittable (is that even a word?) images while browsing. Do you have any idea's if that is possible / how I would go about that? Any code I test seems to create stuttering at some point, whether I try to run code before, during or after tweening. There is always some trade-off that seems to have to be made.

Link to comment
Share on other sites

Nothing comes to mind immediately, but I'll chew on it and maybe add something to BlitMask to help with this. I'm out of the office until next week, though, so it definitely won't be before then. And I'm not positive I'll be able to come up with something anyway but like I said, I'll chew on it. If you think of anything specific, let me know.

Link to comment
Share on other sites

Thanks for possibly chewing on this. It is the foremost problem I encounter in iOS coding, any help is welcome :D

Link to comment
Share on other sites

  • 2 months later...
if only it would support an easy way to smoothly add more Blittable (is that even a word?) images while browsing


Any news on this ? It would be very great to have blitmask for handling this kind of memory problems :)

Link to comment
Share on other sites

It could be the same as the wrap feature, but with a callback function (an index in args) for requesting the new object to add.

What do you think ?

Link to comment
Share on other sites

No, unfortunately it's just not that easy. It would take some fairly significant re-engineering to add that sort of feature efficiently. And frankly it doesn't really fit with what BlitMask is intended to be. It's not trying to duplicate BitmapScroller - it is meant to be an easy way to add a rectangular mask to an existing DisplayObject and leverage blitting techniques to make scrolling much faster. It's not meant to be something that you feed an array of Bitmaps to and have it scroll through them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.