Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
MD5 algorithm
Dialogs - Tell Me Something
Set Cast member Properties of a AVI
Set ImageEnabled Property of a Flash Sprite
Hold on a frame till Flash finishes playing
VideoCodecCheck
Image capture Xtra
CatFlip
Frame Trigger-Alphamania
Wait for DigitalVideo End
MediaMacros Xtras Mall
 

 

 

Behavior Convert Colour Image to Grayscale

Added on 10/25/2005

 

Compatibilities:
D7 D8 D8_5 D9 Mac PC Script

This item has not yet been rated

Author: Chunick (website)

This will allow the user to convert any colour image to grayscale. There are 4 "modes" to choose from. Test it to discover the differences. The code should be placed in a movieScript.

on grayScaleImg (theImage, theMethod)
grayImage = theImage.duplicate()

Case theMethod of
1:
newImage = image(grayImage.width, grayImage.height, 8, #grayscale)
newImage.copyPixels(grayImage, grayImage.rect, grayImage.rect, [#dither: 1215]) -- 1969, 1215
grayImage = newImage

2:
newImage = image(grayImage.width, grayImage.height, 8, #grayscale)
newImage.copyPixels(grayImage, grayImage.rect, grayImage.rect, [#dither: 1969])
grayImage = newImage

3:
theWidth = grayImage.width - 1
theHeight = grayImage.height - 1
repeat with x = 0 to theWidth
repeat with y = 0 to theHeight
theColour = grayImage.getPixel(point(x,y))
-- commented out one is not as rich, but brings out more detail, potentially
-- grayComp = (0.2980 * theColour.red) + (0.5882 * theColour.green) + (0.1138 * theColour.blue)
-- the below uses these fractions: 54/255 R, 182.5/255 G, 18.5/255 B
grayComp = (0.2125 * theColour.red) + (0.7154 * theColour.green) + (0.0721 * theColour.blue)
grayImage.setPixel(point(x,y), color(grayComp, grayComp, grayComp))
end repeat
end repeat

4:
theWidth = grayImage.width - 1
theHeight = grayImage.height - 1
repeat with x = 0 to theWidth
repeat with y = 0 to theHeight
theColour = grayImage.getPixel(point(x,y))
-- not as rich, but brings out more detail, potentially
-- uses these fractions: 76/255 R, 150/255 G, 29/255 B
grayComp = (0.2980 * theColour.red) + (0.5882 * theColour.green) + (0.1138 * theColour.blue)
grayImage.setPixel(point(x,y), color(grayComp, grayComp, grayComp))
end repeat
end repeat

end Case

return grayImage
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail