BitmapData is a very powerful class which, if used properly, can lead to huge performance increase.
Mostly an image is drawn using 2 methods, draw or copyPixels, but what is the real difference of those?
The
draw method contains more parameters than the copyPixels, for example
with copyPixels it is not possible to dynamically transform the image (
scale, move, rotate, etc...).
draw(source:
IBitmapDrawable, matrix:
Matrix = null, colorTransform:
ColorTransform = null, blendMode:
String = null, clipRect:
Rectangle = null, smoothing:
Boolean = false):
voidcopyPixels(sourceBitmapData:
BitmapData, sourceRect:
Rectangle, destPoint:
Point, alphaBitmapData:
BitmapData = null, alphaPoint:
Point = null, mergeAlpha:
Boolean = false):
voidAlso copyPixels can only draw another BitmapData, instead of any given IBitmapDrawable.
Using copyPixels, though, can be multiple times faster than using a draw method.
Here there is a benchmark of the draw and copyPixels method.