Home > Personal Projects > AS3 bitmap mosaic class

AS3 bitmap mosaic class

October 1st, 2008

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.

Julian Personal Projects , , ,

  1. October 2nd, 2008 at 13:05 | #1

    Very cool

  2. Ced
    November 9th, 2008 at 11:15 | #2

    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]

  3. December 4th, 2008 at 07:35 | #3

    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!

  4. January 9th, 2009 at 14:55 | #4

    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.

  5. January 9th, 2009 at 16:24 | #5

    oh yeah here’s the link to as3 apex http://as3apex.com

  6. Julian
    January 9th, 2009 at 16:56 | #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. January 9th, 2009 at 17:13 | #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. January 9th, 2009 at 19:40 | #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. February 12th, 2009 at 12:10 | #9

    Thanks, I need this class,

  1. October 2nd, 2008 at 00:42 | #1
  2. November 3rd, 2008 at 21:01 | #2
  3. May 19th, 2009 at 14:30 | #3