BlendModes & Blur

  1. [SWF(width = 750, height = 750)]
  2. var canvas:BitmapData = new BitmapData(750,1000,false, 0x000000);
  3. addChild(new Bitmap(canvas));
  5. var loader:Loader = new Loader();
  6. loader.load(new URLRequest(""));
  7. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
  8. var bit:BitmapData
  9. var blurred:BitmapData;
  10. function onLoaded(evt:Event):void{
  11.     bit = Bitmap(;
  12.     blurred = bit.clone();
  13.     blurred.applyFilter(blurred, blurred.rect, new Point(0,0), new BlurFilter(4, 4, 6));
  14.     var blends:Array = [BlendMode.NORMAL,BlendMode.ADD, BlendMode.DARKEN,BlendMode.HARDLIGHT,BlendMode.LIGHTEN, BlendMode.MULTIPLY, BlendMode.OVERLAY,BlendMode.SCREEN, BlendMode.DIFFERENCE];
  15.     var m:Matrix = new Matrix();
  16.     for (var i:int = 0; i<blends.length; i++){
  17.         m.tx = i % 3 * 250;
  18.         m.ty = int(i / 3) * 250;
  19.         canvas.draw(bit, m);
  20.         if (i> 0){
  21.         canvas.draw(blurred, m, null, blends[i]);
  22.         }
  23.     }
  24. }

When I used to use photoshop for more than just the most basic of things, I would use a simple technique that employed layer modes (blend modes in flash) and blur. Sometimes, if I had a low quality image that I wanted to make look a little better, or just wanted to give an image a subtle effect, I would duplicate the layer the image was on, blur it and then go through all the layer modes on that duplicate layer until I found something I liked.

This snippet does the same thing with a few select blend modes:

This isn't the greatest image to illustrate the effect, but I didn't feel like digging something better up. Two notable swatches are the upper right (darken) and the lower middle (screen).

This entry was posted in BitmapData, misc and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted July 16, 2009 at 9:39 am | Permalink

    Interesting , the difference mode is often used for edge detection, interestingly enough it works regardless of the lighting conditions. Thanks for sharing Zevan!

  2. Posted July 16, 2009 at 10:34 am | Permalink

    yeah… I have yet to mess with augmented reality stuff - I’ll have to look into it at some point. If you do a ColorMatrixFilter you can really bring out the edges and convert it to grayscale.

  3. Posted July 16, 2009 at 2:46 pm | Permalink

    Zevan, you should start posting your snippets on - seems like a match made in heaven.

    Also, cody sucks.

  4. Posted July 16, 2009 at 2:53 pm | Permalink

    yeah I was looking around to see if there was a way I could automatically post to wonderfl… cuz I’m too lazy to copy and paste and convert everything to a document class…

    It’s funny, my brothers name is also Cody so for a second I thought you were talking about him… then I realized you were talking about Cody Greelhalge (that is who you’re talking about right?)…

  5. Posted July 16, 2009 at 5:18 pm | Permalink

    Haha yeah, i was referring to the greenhalge variety.

    I see what you’re saying, though, but still a shame :)

  6. Posted July 16, 2009 at 5:26 pm | Permalink

    wonderful is great, but last I checked you couldn’t do a simple sort all code posted by date from all users… is that possible now? it always bugged me before… part of the reason I didn’t invest more time in some kind of autopost thing…

Post a Comment

Your email is never published nor shared. Required fields are marked *