Image Filter art-rotating blur filter and image filter art ---

Source: Internet
Author: User
Tags image filter

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.

Related Article

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.