Image Filter art-rotating blur filter and image filter art ---
This article introduces an algorithm for rotating a fuzzy filter. The main feature of rotation blur is that the entire image is rotated around a central point. At the same time, there is a variable that controls the degree of rotation and a variable that controls the degree of blur to achieve this effect. The closer the image is to the center, the smaller the degree of rotation and blur. Assume that the O coordinate of the center is (cenX, cenY), the current point is P (x, y): 1, and the PO distance is Dis = Math. sqrt (y-cenY) * (y-cenY) + (x-cenX) * (x-cenX); 2. angle Between PO and horizontal direction = Math. atan2 (double) (y-cenY), (double) (x-cenX); 3. Calculate the new coordinates newX and newY after the rotation of the current vertex P: newX = Dis * Math. cos (angle) + cenX; newY = Dis * Math. sin (angle) + cenY; the complete C # code is provided below: /// <summary> /// Rotate Blur /// </summary> /// <param name = "src"> Source image. </param> /// <param name = "cenX"> The X position of Blur. </param> // <param name = "cenY"> The Y position of Blur. </param> // <param name = "intensity"> The intensity of blur, 0-100. </param> // <returns> The result image. </returns> private Bitmap RotateBlurProcess (Bitmap srcBitmap, int cenX, int cenY, int intensity) {Bitmap a = new Bitmap (srcBitmap); int w =. width; int h =. height; cenX = Math. min (w-1, Math. max (0, cenX); cenY = Math. min (h-1, Math. max (0, cenY); Bitmap dst = new Bitmap (w, h); System. drawing. imaging. bitmapData srcData =. lockBits (new Rectangle (0, 0, w, h), System. drawing. imaging. imageLockMode. readWrite, System. drawing. imaging. pixelFormat. format32bppArgb); System. drawing. imaging. bitmapData dstData = dst. lockBits (new Rectangle (0, 0, w, h), System. drawing. imaging. imageLockMode. readWrite, System. drawing. imaging. pixelFormat. format32bppArgb); unsafe {byte * pIn = (byte *) srcData. scan0.ToPointer (); byte * pOut = (byte *) dstData. scan0.ToPointer (); byte * p = null; int stride = srcData. stride-w * 4; int newX = 0, newY = 0; double angle = 0; double temp = 0, r = 0, g = 0, B = 0; for (int y = 0; y Source image Given a complete DEMO program: http://www.zealpixel.com/forum.php? Mod = viewthread & tid = 148 & extra = page % 3D1 to share with you! |
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.