Spicy Chicken GDI in C #

Source: Internet
Author: User

1.Draw Directly XXXX ...

2.Memory + DrawImage XXX > 5fps

3.Memory + BitBlt XX > 15fps

usingSystem;usingSystem.Collections.Generic;usingSystem.Drawing;usingSystem.Drawing.Drawing2D;usingSystem.Linq;namespaceyozora{ Public structDot { Public floatX, Y;  Public floatVx, Vy;  Public floatRadius;  Publiccolor color; StaticRandom random =NewRandom ((int) DateTime.Now.ToBinary ());  PublicDot (intWidthintheight, color color) {X= (float) Random. Nextdouble () *width; Y= (float) Random. Nextdouble () *height; Vx= -0.5f+ (float) Random.            Nextdouble (); Vy= -0.5f+ (float) Random.            Nextdouble (); Radius= (float) Random. Nextdouble () *2; Color=color; }    }     Public classDotmgr {Privatedot[] Dot_array_; //The width of lines        PrivateInt32 b_ =1; //The quanlity of Dots        Private floatD_ =0.2f; //The origin and bitmap graphics        PrivateGraphics Dst_g_, Mmr_g_; //        PrivateBitmap m_; //width        PrivateInt32 W_ =1920x1080; //Height        PrivateInt32 H_ = -; //The limit of FPS        PrivateInt32 f_ = -; //The quanlity of stars        Private floatS_ =0.2f; //The lines of stars        PrivateInt32 L_ =5; PrivateIntPtr mmr_dc_ =IntPtr.Zero; PrivateIntPtr dst_dc_ =IntPtr.Zero;  Public BOOLOK =true;  PublicINF Init (Graphics g, Int32 width, Int32 height, Int32 frame,floatStarsfloatdots) {Dst_g_=G; W_=width; H_=height; F_=frame; S_=stars; D_=dots; M_=NewBitmap (W_, H_); Mmr_g_=graphics.fromimage (m_); Dst_g_.            Clear (Color.Black); Mmr_dc_=Mmr_g_.            GetHdc (); Dst_dc_=Dst_g_.            GetHdc (); Mmr_g_.            RELEASEHDC (); return NewINF (0,"success Init."); }         Public voidcreatedots () {} Publicinf Drawstar () {inf inf=NewINF (2,"Start Drawing"); Mmr_g_. FillRectangle (NewSolidBrush (Color.FromArgb (255,0,0,0)),0,0, W_, H_);            Int32 x, Y, R1, R2; Int32 Angle= the/L_; Int32 L= L_ *2; Point[] Star=Newpoint[l+1];            Color color;            Pen p; Random Rnd=NewRandom ();  for(Int32 i =0; I < w_ * S_; ++i) {x= rnd. Next (Ten, W_-Ten); Y= rnd. Next (Ten, H_-Ten); // ?R1 = rnd. Next (4,7); R2= rnd. Next (8, A); Color= Color.FromArgb ( -, Rnd. Next (1,254), Rnd. Next (1,254), Rnd. Next (1,254)); P=NewPen (color, b_);  for(Int32 j =0; J < L +1; ++j) {Star[j]. X= Convert.ToInt32 (Math.Round (j%2==0? (x + r1 * Math.Cos (J *3.14159/L_)): (x + r2 * Math.Cos (J *3.14159/L_)),2, Midpointrounding.awayfromzero)); STAR[J]. Y= Convert.ToInt32 (Math.Round (j%2==0? (Y + r1 * Math.sin (J *3.14159/L_)): (Y + r2 * Math.sin (J *3.14159/L_)),2, Midpointrounding.awayfromzero)); } mmr_g_.                DrawLines (P, star); if(Rnd. Next (0, -) > -) Mmr_g_. FillPolygon (NewSolidBrush (color), star); } OK=true;
Spciy Chicken W32. SelectObject (Mmr_dc_, m_. Gethbitmap ()); W32. BitBlt (DST_DC_,0,0, W_, H_, MMR_DC_,0,0, W32. SRCCOPY); return NewINF (1,"Draw successfully!"); } }}

Spicy Chicken GDI in C #

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.