AS3 bitmap mosaic class

This class will allow you to create a pixellated copy of any display object.

It allows for varying pixel sizes and caching of rendered pixels so you don’t have to redraw them every time.

mosaic

Usage is as follows:

var myMoz:Mosaic = new Mosaic(yourDisplayObj:DisplayObject, pixelSize:uint, useCache:Boolean);
addChild(myMoz);

or

var myMoz:Mosaic = new Mosaic(yourDisplayObj);
myMoz.pixelSize = 10;
myMoz.render();

Give it a try and let me know what you think.

35 thoughts on “AS3 bitmap mosaic class

  1. Pingback: Actionscript Classes » Bitmap Mosaic

  2. Pingback: combinecreative.com » Blog Archive » AS3 bitmap mosaic class

  3. Hello,

    Nice job but i have a problem trying to use it in Full Browser. I put a mosaic image in background (full browser), and the image is supposed to resize when i resize my window. It works well but the mosaic image sometimes draw horizontal and vertcal outlines around the mosaics…

    Is it normal ? Is it possible to fix it ?

    Thank You !

    Cédric from Montreal…

    [Cedric, your stage scale mode is probably set to EXACT_FIT which is the default. To fix this you should set it to NO_SCALE. Of course after doing that you'd need to listen for a RESIZE event from the Stage and do all your other element's resizing manually through code. Hope this helps - JK]

  4. hey there!
    I’m trying to use this class but I get this error:

    Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.

    Any help?
    Cheers!

  5. Hi julian,

    Nice work, though I thought to change it a bit.
    You can have a look here.
    http://gfxcomplex.com/MosaicFilter.zip

    I like the use of graphics better, because you can use the clear() method to clean old graphics faster then you can using removeChild() and creating extra vars for holding pixels.

    That and I added most stander compliant coding. I would not recommend using public vars ever.

    PS: I run the AS3 User group in st.Louis, you should come to visit. Your a good code, but I think you could use some help on standers.

  6. One thing missing now though is the caching I had built in. That way once you draw a 10px Mosaic, you can access it again at any time without redrawing it.

  7. The BitmapData.draw() only happens once. Thats the slowest method of the class.

    I have got this to work with video at 3 pixel size at 60fps with no problem

    this is really fast, the only thing I could think to make this work faster would be to use a Vector class.

    I guess I would need to see a real world use where I would need the cashed shape.

  8. I Just updated the zip again. this Time I did it with pixel bender. super fast!
    Note: this only work with flash 10.

    If you don’t have flash 10, I could show you how to use flash develop with the flex 4 sdk to compile flash 10 for free.

  9. Pingback: Mosaic effect | Aleksey Matveev blog

  10. Pingback: Mosaic Class, different tests at Helpful stuff

  11. Hey Julian.

    This is really cool, but do you know if this can be done with a png that has a transparent background?

    Cordially
    Vayu

  12. Hi again.

    I actually found the answer to my own question about the transparent png.

    In the Mosaic.as I changed the getPixel function to getPixel32.

    var color:uint = bmd.getPixel(colorX , colorY);
    to
    var color:uint = bmd.getPixel32(colorX , colorY);

    Let me know if there is a problem with this.

  13. Pingback: 8 Classical ActionScript Classes About BitMap - Ntt.cc

  14. Pingback: 8?bitmap??? | ??-????

  15. Pingback: RIACOOL'BLOG | 8?bitmap???

  16. Pingback: AS???????? « Deepin 3000

  17. Pingback: AS???????? « Deepin 3000

  18. Pingback: 8 Classical ActionScript Classes About BitMap | Adobe Show Center

  19. Pingback: AS???????? ? Ase7en’Blog

  20. Pingback: 8?bitmap??? « echo "RenYuan's Blog"

  21. Pingback: AS3?????????????? | AS3??

  22. Pingback: AS???????? | ???????

  23. Pingback: as518.com

  24. Pingback: ????? » AS????????

  25. Pingback: 8?bitmap??? - ChinemitBlog

  26. Pingback: AS???????? ? ???????

  27. @Josh, Julian

    Great class, very nice work – short, sweet and effective!

    One question, though – the pixelation happens from top-left (0,0). Any chance of pointers to get it working from another position, say perhaps the centre (but ideally any co-ordinate)?

    thanks

  28. Pingback: ??? » Blog Archive » ??bitmap???

  29. This class is awesome! Thanks so much for sharing.

    I did ran into a problem. The Mosaic filter works fine when running locally, but as soon as I place the swf on a webserver, the Flash movie halts at the moment of creating the class instance. Any clue what goes wrong here?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>