VII. Diffusion
Move the color values of random points within the range of xoffset and yoffset to the current position for display. Another way is to move the current vertex to another position for display. P1 +Stride*Yin+Xin*3 is the offset calculation method.1PublicStaticBoolDiffuse (Bitmap B,IntXoffset,IntYoffset,IntStep) 2{ 3Bitmapdata bmdata=B. lockbits (NewRectangle (0,0, B. Width, B. Height ), 4Imagelockmode. readwrite, pixelformat. format24bpprgb ); 5IntStride=Bmdata. stride; 6System. intptr scan0=Bmdata. scan0; 7Unsafe 8{ 9Byte*P=(Byte*)(Void*) Scan0; 10Byte*P1=P; 11IntNoffset=Stride-B. Width*3; 12Random Rad=NewRandom (); 13For(IntY=0; Y<B. height;++Y) 14{ 15For(IntX=0; X<B. width;++X) 16{ 17If(Y%Step=0&&X%Step=0) 18{ 19IntXin=Rad. Next (2*Xoffset)-Xoffset+X; 20IntYin=Rad. Next (2*Yoffset)-Yoffset+Y; 21If(Xin<1) Xin=0; 22ElseIf(Xin>B. Width-1) Xin=B. Width-1; 23If(Yin<1) Yin=0; 24ElseIf(Yin>B. Height-1) Yin=B. Height-1; 25Byte*Ptemp=P1+Stride*Yin+Xin*3; 26P [0]=Ptemp [0]; 27P [1]=Ptemp [1]; 28P [2]=Ptemp [2]; 29} 30P+ =3; 31} 32P+ =Noffset; 33} 34} 35B. unlockbits (bmdata ); 36ReturnTrue; 37}
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