One, the computer display graphics can generally be divided into two categories--vector map and bitmap.
Vector graphs (vectors): Use lines and curves to describe a graphic whose elements are dots, lines, rectangles, polygons, circles, arcs, and so on, all of which are computed by mathematical formulas. It is well known that Flash is a vector animation software. The colors used in the AS (Beginfill), drawing lines (LineTo) are based on the operation of the vector graph.
Bitmap (BITMAP): Generally used for photographic quality image processing, is composed of many like small squares of the same pixel composition of the graphics. Simply put, a bitmap is a pattern made up of countless color points. Bitmap (Bitmap) is what we're going to introduce today.
Compare the two:
1. Vector graphs can be enlarged infinitely without distortion and the bitmap will be distorted.
2. Bitmaps consist of pixels and vector graphs are composed of vector lines.
3. Bitmaps can show more colors, while vector graphs are relatively few.
4. Vector graph small size, but the comparison of consumption of computing resources; Bitmaps compare memory resources, but they consume less computational resources.
Second, the concept of BitmapData class
The BitmapData class can be used to create transparent or opaque bitmap images in a document that can be resized arbitrarily, and can be processed in various ways at run time. You can think of a BitmapData object as a special array, which is designed to store the pixel lattice information of a bitmap. If a bitmap size is 100*100, then BitmapData is like a two-dimensional array stored in a 100*100 that corresponds to a color value that stores these 10000 pixels.
Third, the use of BitmapData class
import flash.display.BitmapData;
//导入BitmapData类
var bm = new BitmapData(width,height,transparent,fillcolor);
//实例化
Iv. BitmapData Constructors
public BitmapData(width, height, [transparent], [fillColor])
Width (width): size of bitmap data (pixel);
Height (high): Bitmap data height (in pixels);
[Transparent (transparency)]: support for each pixel with different transparency;
[FillColor color]: Used to populate the bitmap image area. The default is 0xFFFFFFFF (white)
*[Bracket] Indicates an optional argument
For example (to create a 100*100 bitmap data):
import flash.display.BitmapData;
var bm:BitmapData = new BitmapData(100,100,false,0xffff00)