CopyPixels

From Director Online Wiki
Jump to: navigation, search
copyPixels
Type: method
Version: 8.0 and up
Language: Lingo, JavaScript
Dependencies: none
Links/Related
color(), image()

Copies the contents of a rectangle in an existing image object into a new image object.

Syntax

from MX 2004 Documentation

 imageObjRef.copyPixels(sourceImgObj, destRectOrQuad, sourceRect {, paramList})

Undocumented Syntax

From Werner Sharp, the engineer at Macromedia who worked on Imaging Lingo:

"Transform bitmap in authoring uses a high-quality dithering and remapping algorithm which is a lot slower than the one that copyPixels uses. You'll get slightly different results, especially for subtle variations of color. There's an undocumented feature in imaging lingo to get these same effects but you should be sure to check performance implications. If you pass in values for the dither parameter in copyPixels, you can get the same effects as transform bitmap.

Use [#dither:1215] - This uses a remapping algorithm that searches the palette for the closest color instead of using 5 bits of R, G and B to find a color. Good for very subtle palettes with lots of very similar colors.

Use [#dither:1969) - This uses a high-quality dithering algorithm with better results than the regular dither, but a lot slower.

These are undocumented, unsupported, etc. They worked when I put them in, but I haven't tried them out in a long time."

Bugs/Quirks/Problems

There are some cross-platform discrepancies, and some windows-specific bugs. Most of the time those can be worked around by using 16 bits image objects.

Related Note

if you need performance, instead of using member images, you can copypixels directly into (the stage).image, which is much faster. Also try to use copypixels no more than necessary, by storing image objects that you might use several times into variables.