I am new to ActionScript. If I understand correctly, DisplacementMapFilter moves pixels from the "source image" according to the color of the corresponding pixel position in the "MAP image".
The problem is that my destination image contains pixels that are NOT in the original image!
For example, I take the original UNICOLOR image of 10 * 10 pixels with this BitMapData:
sourceBitmap = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT, false, 0x000002); produce: 0 1 2 3 4 5 6 7 8 9 [002,002,002,002,002,002,002,002,002,002] Row 0 [002,002,002,002,002,002,002,002,002,002] Row 1 [002,002,002,002,002,002,002,002,002,002] Row 2 [002,002,002,002,002,002,002,002,002,002] Row 3 [002,002,002,002,002,002,002,002,002,002] Row 4 [002,002,002,002,002,002,002,002,002,002] Row 5 [002,002,002,002,002,002,002,002,002,002] Row 6 [002,002,002,002,002,002,002,002,002,002] Row 7 [002,002,002,002,002,002,002,002,002,002] Row 8 [002,002,002,002,002,002,002,002,002,002] Row 9
Now, I take this BLACK MAP move and I add a little BLUE square:
displacementBitmap = new BitmapData(BITMAP_WIDTH,BITMAP_HEIGHT,false,0x000000); for(i=5;i<10;i++) for(j=5;j<10;j++) displacementBitmap.setPixel(i,j,255); produce: 0 1 2 3 4 5 6 7 8 9 [000,000,000,000,000,000,000,000,000,000] Row 0 [000,000,000,000,000,000,000,000,000,000] Row 1 [000,000,000,000,000,000,000,000,000,000] Row 2 [000,000,000,000,000,000,000,000,000,000] Row 3 [000,000,000,000,000,000,000,000,000,000] Row 4 [000,000,000,000,000,255,255,255,255,255] Row 5 [000,000,000,000,000,255,255,255,255,255] Row 6 [000,000,000,000,000,255,255,255,255,255] Row 7 [000,000,000,000,000,255,255,255,255,255] Row 8 [000,000,000,000,000,255,255,255,255,255] Row 9
Result:
displacementFilter = new DisplacementMapFilter(); displacementFilter.alpha=0; displacementFilter.color=0; displacementFilter.mapPoint=new Point(0,0); displacementFilter.scaleX=1; displacementFilter.scaleY=1; displacementFilter.componentX = flash.display.BitmapDataChannel.BLUE; displacementFilter.componentY = flash.display.BitmapDataChannel.BLUE; displacementFilter.mapBitmap = displacementBitmap; destinationBitmap = new BitmapData(BITMAP_WIDTH,BITMAP_HEIGHT,false,0xFFFFFFFF); destinationBitmap.applyFilter( sourceBitmap.bitmapData, new Rectangle(0,0,BITMAP_WIDTH,BITMAP_HEIGHT), new Point(0,0), displacementFilter ); produce: 0 1 2 3 4 5 6 7 8 9 [002,002,002,002,002,002,002,002,002,002] Row 0 [002,002,002,002,002,002,002,002,002,002] Row 1 [002,002,002,002,002,002,002,002,002,002] Row 2 [002,002,002,002,002,002,002,002,002,002] Row 3 [002,002,002,002,002,002,002,002,002,002] Row 4 [002,002,002,002,002,001,001,001,001,001] Row 5 [002,002,002,002,002,001,001,001,001,001] Row 6 [002,002,002,002,002,001,001,001,001,001] Row 7 [002,002,002,002,002,001,001,001,001,001] Row 8 [002,002,002,002,002,001,001,001,001,001] Row 9
Therefore, I donโt understand why I have the โ001โ pixels that are not in the original image.
Thank you very much.