Image Filter Art---wave filter

Source: Internet
Author: User
Tags image filter

Wave Filter Wave filterWater filter is a coordinate transformation to simulate the effect of water waves, so that the image presents the effect of water wave. This filter has an adjustable parameter: the degree of distortion of the water waves. The code is as follows;//       ///       //Wave filter       ///  &NB Sp    /// source image.       /// the degree of wave,0-100.      &NB Sp  the result image.        Private Bitmap wavefilterprocess (Bitmap srcbitmap, int degree) &nbsp ;       {            Bitmap a = new Bitmap (srcbitmap);      &NBS P     int w = a.width;            int h = a.height;        &NBSP ;   degree = degree * 32/100;            degree = Math.max (0, Math.min (+ degree)); &nb Sp           BITMAP DST = new Bitmap (w, h);            System.Drawing. Imaging.bitmapdata srcdata = a.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.ToPo Inter ();                byte* pOut = (byte*) dstData.Scan0.ToPointer ();  &nbsp ;             byte* p = null;                int Strid E = srcdata.stride-w * 4;                int newx = 0, Newy = 0;    &N Bsp           Double PI2 = Math.PI * 2.0;                  FOR (int y = 0; y < h; y++)                 {          &N Bsp         for (int x = 0; x < W; + +)                   and nbsp {                        NEWX = (int) (degree * Math.sin (PI2 * y/128.0) + x;                        newy = (int) (degree * Math.Cos (PI2 * x/128.0)) + y;                        NEWX = Math.min (w-1, Math.max (0, newx));                        NEW Y = Math.min (h-1, Math.max (0, Newy));                        p = pIn + newy * srcdata.stride + newx * 4;                      and nbsp POUT[0] = (byte) p[0];                        pout[1] = (byte) p[1];&nb Sp                       pout[2] = (byte) p[2];      &NB Sp                 pout[3] = (byte) 255;                                 &NBSP ;           POut + + 4;                   }                    POut + stride;            & nbsp  }                a.unlockbits (srcdata);          & nbsp     DST. Unlockbits (dstdata);           }            return DST;
Following

Original

Wave Filter

Finally put a complete C # version of the program demo:http://www.zealpixel.com/thread-59-1-1.html

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Image Filter Art---wave filter

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.