Image Filter art-squeeze filter, filter Pinch
Pinch filter the Pinch filter uses Coordinate Transformation to achieve the effect of squeezing and deformation from an image within a certain radius of R at the center of a certain point (cenX, cenY. There are many algorithms to implement this filter, mainly because of the differences in mathematical formulas. You can design it yourself. Here is a sample code that you can use directly. The Code is as follows: // <summary> // Pinch Filter // </summary> // <param name = "src"> Source image. </param> /// <param name = "cenX"> The X position of sun. </param> // <param name = "cenY"> The Y position of sun. </param> // <returns> The result image. </returns> private Bitmap PinchFilterProcess (Bitmap srcBitmap, int cenX, int cenY) {Bitmap a = new Bitmap (srcBitmap); int w =. width; int h =. height; int radius = 0; 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 sWidth = srcData. stride; int stride = sWidth-w * 4; int offsetX = 0, offsetY = 0; int newX = 0, newY = 0; double radian = 0, degree = 10; for (int y = 0; y : Source image Pinch Filter Finally put a complete C # version of the program Demo for everyone to download the use of: http://www.zealpixel.com/forum.php? Mod = viewthread & tid = 55 & extra = page % 3D1 |
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.