[As Functional code Tutorial 08] Bitmap dynamic Effect

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.