<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                本文介紹一種旋轉模糊濾鏡的實現算法。 旋轉模糊主要特點是:整張圖像圍繞一個中心點做旋轉變換,同時有個控制旋轉程度的變量和一個控制模糊程度的變量,來完成這個效果。圖像中距離中心點越近,旋轉和模糊的程度都越小,反之,越大。 假設中心點O坐標為(cenX,cenY),當前點位置為P(x,y): 1,PO距離Dis=Math.Sqrt((y - cenY) * (y - cenY) + (x - cenX) * (x - cenX)); 2,PO和水平方向夾角angle=Math.Atan2((double)(y - cenY), (double)(x - cenX)); 3,當前點P對應的旋轉后新的坐標newX,newY計算: newX = Dis?* Math.Cos(angle) + cenX; newY = Dis *?Math.Sin(angle) + cenY; 下面給出完整的C#代碼: ~~~ /// <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 = a.Width; int h = a.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 = 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.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 < h; y++) { for (int x = 0; x < w; x++) { r = 0; g = 0; b = 0; temp = Math.Sqrt((y - cenY) * (y - cenY) + (x - cenX) * (x - cenX)); angle = Math.Atan2((double)(y - cenY), (double)(x - cenX)); for (int n = 0; n < intensity; n++) { angle = angle + 0.005; newX = (int)(temp * Math.Cos(angle) + (double)cenX); newY = (int)(temp * Math.Sin(angle) + (double)cenY); newX = Math.Min(w - 1, Math.Max(0, newX)); newY = Math.Min(h - 1, Math.Max(0, newY)); p = pIn + newY * srcData.Stride + newX * 4; b = b + p[0]; g = g + p[1]; r = r + p[2]; } b = Math.Min(255, Math.Max(0, b / intensity)); g = Math.Min(255, Math.Max(0, g / intensity)); r = Math.Min(255, Math.Max(0, r / intensity)); pOut[0] = (byte)b; pOut[1] = (byte)g; pOut[2] = (byte)r; pOut[3] = (byte)255; pOut += 4; } pOut += stride; } a.UnlockBits(srcData); dst.UnlockBits(dstData); } return dst; } ~~~ 最后,看下效果圖: [![](https://box.kancloud.cn/2016-01-05_568b3326edd01.jpg)](http://www.zealpixel.com/data/attachment/portal/201509/15/143909xts7rcps466mst27.jpg) 原圖 [![](https://box.kancloud.cn/2016-01-05_568b332712f15.png)](http://www.zealpixel.com/data/attachment/portal/201509/15/143912qmvpwqpqvrvj1m1p.png) 效果圖 給出一個完整DEMO程序的下載地址:[http://www.zealpixel.com/forum.php?mod=viewthread&tid=148&extra=page%3D1](http://www.zealpixel.com/forum.php?mod=viewthread&tid=148&extra=page%3D1)?跟大家分享一下!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看