TubeView -filter
version in actionScript 3.0, using two DisplacementMapFilters
... scroll the mouse wheel for zooming or use arrows Up and Down
But why two displacementMaps ? 'cos one can only shift a pixel
within a range of -127*scale to 127*scale pixels !
The idea breafly with some extracts from the code:
// creating two displacementMaps,
// we have the needed displacement (dx, dy),
// from that amount the lower bytes create 'dismapLo', the higher 'dismapHi'
...
var green:int = dx*0x10 +0x8080; // multiplied by 16:
var blue:int = dy*0x10 +0x8080; // smallest shift 1/16 pixel for better quality
dismapHi.setPixel(x,y, (green & 0xFF00) | (blue>>8) );
dismapLo.setPixel(x,y, (green & 0xFF) <<8 | (blue & 0xFF) );
...
// nb: the scaling of bitmaps !
var displaceHi:DisplacementMapFilter= new DisplacementMapFilter(dismapHi,
new Point(x-bmp.width,y-bmp.height),
BitmapDataChannel.GREEN, BitmapDataChannel.BLUE,
0x1000,0x1000, // larger shift !
DisplacementMapFilterMode.COLOR, 0x0,0.0);
// use mode īCOLORī gives the effect on the edges of the bitmap
var displaceLo:DisplacementMapFilter= new DisplacementMapFilter(dismapLo,
new Point(x-bmp.width,y-bmp.height),
BitmapDataChannel.GREEN, BitmapDataChannel.BLUE,
0x10,0x10, // smaller shift !
DisplacementMapFilterMode.COLOR, 0x0,0.0);
bmp.applyFilter(bmpOriginal,new Rectangle(0,0,bmp.width,bmp.height), new Point(0,0) ,displaceHi);
bmp.applyFilter(bmp,new Rectangle(0,0,bmp.width,bmp.height), new Point(0,0) ,displaceLo);
...
by Petri Leskinen, Feb 2008