About Flash pixel Operation Setpixels,setvector,copypixels,draw Performance comparison

Source: Internet
Author: User

make some corrections for Bowen Http://www.cnblogs.com/heycup/archive/2011/01/24/1943012.html

Setvector in the original text SetPixels's test is problematic. He misled the Getvector getpixels some classmates, and did not know how much to read the blog's belief in it, but the last of the "hands are more meaningful" I very much agree.

I made a few changes to the code inside, removing all the extra performance costs.

1 varShape:shape =NewShape ();2Shape.graphics.beginFill (0xff0000);3Shape.graphics.drawRect (0, 0, 300, 300);4 Shape.graphics.endFill ();5 6 varBmd1:bitmapdata =NewBitmapData (2000, 2000);7 varBmd2:bitmapdata =NewBitmapData (300, 300);8 Bmd2.draw (shape);9 Ten varRect:rectangle =NewRectangle (10,10,80,80); One  A vararr:vector.<uint> = Bmd2.getvector (NewRectangle (10, 20, 80, 80)); - varStart:int =Gettimer (); -  for(varJ:int = 0; J < 9999; J + +) { the bmd1.setvector (rect, arr);  - } -Trace"Setvector", Gettimer ()-start); -  + varArr2:bytearray = Bmd2.getpixels (NewRectangle (10, 20, 80, 80)); -Start =Gettimer (); +  for(j = 0; J < 9999; J + +) { Aarr2.position = 0; at bmd1.setpixels (rect, arr2);  - } -Trace"SetPixels", Gettimer ()-start); -  - varPoint:point =NewPoint (10, 10); -Start =Gettimer (); in  for(j = 0; J < 9999; J + +) { - bmd1.copypixels (BMD2, rect, point); to } +Trace"CopyPixels", Gettimer ()-start); -  the varMatrix:matrix =NewMatrix (0.8,0,0,0.8); *Start =Gettimer (); $  for(j = 0; J < 9999; J + +) {Panax NotoginsengBmd1.draw (Bmd2,matrix,NULL,NULL, rect); - } theTrace"Draw", Gettimer ()-start);

The test results are as follows

This is the effect of the release version because it is using Flash CS.

Conclusion Copypixels>setvector>draw>setpixels Although the results are consistent with the original text but the performance differences are not as exaggerated as in the original

I tried to add the number of loops to 99999.

Can see Setvector draw setPixels Three methods The gap is not really big

About Flash pixel Operation Setpixels,setvector,copypixels,draw Performance comparison

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.