2

I want to implement various effects like Sepia, GrayScale, Posterization etc. on BitmapData in ActionScript-3.

How to do this and What is most efficient way to do this ?

Thanks in advance!!

Jacob Poul Richardt
  • 3,145
  • 1
  • 26
  • 29
DexTer
  • 2,043
  • 1
  • 22
  • 45
  • Sepia, GrayScale you can get away with a [ColorMatrixFilter](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/ColorMatrixFilter.html), Posterization probably can be done using the [ConvolutionFilter](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/ConvolutionFilter.html). If your target audience has Flash Player 10 installed, I would suggest following @James' advice and look into PixelBender. Should be faster in most cases(not entirely sure if true for all, e.g. for blur), and it runs on a separate thread/asynchronous processing – George Profenza Sep 27 '11 at 15:29

2 Answers2

2

The most efficient way to do image processing would be to use Adobe Pixel Bender. This is basically a pixel shader like language that can be used to create filters for Photoshop, After Effects and Flash. There is also an exchange where developers share filters.

Here is a tutorial on how to load pixel bender filter into flash.

There is more information available if you search Google for "pixel bender flash".

James Fassett
  • 40,306
  • 11
  • 38
  • 43
1

This post explains how to do the GrayScale:

AS3:How to change a colored Bitmap's BitmapData to black and white?

Sepia is a combination of grayscale and tinting. Tinting is typically accomplished by multiplying one of the colour channels by a certain amount to boost that colour.

The techniques illustrated in that post are the way you should proceed. You'll have to look up the per-pixel filtering algorithms, but many of them exist on wikipedia or math sites.

Community
  • 1
  • 1
Soviut
  • 88,194
  • 49
  • 192
  • 260