General Information

This Xtra will work on Macintosh and Windows computers. 

This Xtra will let you apply a bunch of Photoshop-like filters to a cast member in runtime. These filters can include "blur", "blur more", "find edges", "motion blur" sharpness", "emboss" and more. The cast member should be an image. 

What the Xtra actually does is perform a 3 X 3 matrix convolution on the pixels of the image. The user can specify the parameters for this operation.

Since the Xtra alters a cast member, you still maintain all the control over the display of the member as a sprite, including ink affects, blends, and layering.

Opening the Xtra.

Put the Xtra in the "Xtras" folder near your Director application. Then call -  

set BlurObj = new(Xtra "BlurImage")

Have BlurObj declared as a Global variable since you will be referring to it later. 

You will probably be doing this in the beginning of the movie so your handler will probably look like this:

on StartMovie
	Global BlurObj 
	if not  BlurObj then		
		set BlurObj = new(Xtra "BlurImage")
	end if
end StartMovie

Closing the Xtra.

When you are done you should close the Xtra by assigning 0 to the variable. 

on StopMovie
  global BlurObj 
  set BlurObj = 0
end


Applying filters to a cast member.


Before you can apply a filter on a cast member you must prepare an additional cast member which will accept the result of the operation. This cast member must be of kind "Image". You can create one by opening the paint window and scribbling something. You can also copy an existing cast 	member.

On Windows machines the source cast member has to be of depth 32 bit color. On Macs any depth will work. The color depth of the screen does not matter in any case.

To apply a filter you call the "Blur" method.
The ApplyFilter(BlurObj, Source, Destination, A1,A2,A3,B1,B2,B3,C1,C2,C3,times ) method  takes thirteen arguments.

BlurObj - The instance returned from New().

Source - An integer which is the number of the cast member to which the filter will be applied.

Destination - An integer which is the number of the cast member that the result of the filter operation will be placed in. Make sure that a cast member of type "Image" does exist in this number.

 -----------------------
|       |       |       |
|  A1   |  A2   |  A3   |
|       |       |       |
 -----------------------
|       |       |       |
|  B1   |  B2   |  B3   |
|       |       |       |
 -----------------------
|       |       |       |
|  C1   |  C2   |  C3   |
|       |       |       |
-----------------------


A1,A2,A3,B1,B2,B3,C1,C2,C3, are all integers that describe the value of specific cells in the 3 X 3 matrix of the filter. 

The best way to determine the numbers that should be used is to try them first using this director sample and then copy the numbers to your own movie you can also try the numbers in photoshop under "Convolution kernel...". 

a second way is to understand what the numbers actually represent: 

The cell B2 is the pixel you will be changing, and the other cells are its immediate neighbors from top bottom left right and the diagonals, as shown in the table above. 

the number that you assign a to a specific cell is actually the amount of influence the corresponding pixel will have on the pixel being changed. a value of 0 is neutral, and does not influence at all, a large number has a large influence, and a negative number has a negative influence. 

For each pixel in your image the computer will check its neighbors and according to the influence of its neighbors will assign a new value for the pixels.

Times - This argument is an integer that describes the number of times the computer will apply the filter on your image. This all takes place in the computer's memory, and a larger number of times will increase the influence of the filter. Note that the larger the number , the longer the operation takes. Passing 0 as the number of times will result in a copy of the original cast member placed in the destination cast member.

A Few Samples:	

Blur - 
Blur(BlurObj,from,to,1,1,1,1,1,1,1,1,1,1)

Blur even more -
Blur(BlurObj,from,to,3,2,3,2,0,2,3,2,3,10)

Find edges - 
Blur(BlurObj,from,to,-1,-1,-1,-1,9,-1,-1,-1,-1,1)

Motion Blur - left right
Blur(BlurObj,from,to,0,0,0,3,1,3,0,0,0,7)

Motion Blur - right left
Blur(BlurObj,from,to,0,3,0,0,1,0,0,3,0,7)

Motion Blur - top right
Blur(BlurObj,from,to,0,0,3,0,1,0,3,0,0,7)

Motion Blur - top left
Blur(BlurObj,from,to,3,0,0,0,1,0,0,0,3,7)

Emboss - 
Blur(BlurObj,from,to,1,1,0,1,3,-1,0,-1,0,-1,-1,1)

For aditional help and purchasing :

www.itp.tsoa.nyu.edu/~danny/Xtras.html

dann@rozin.com


