移动一像素?整行或整列移动吧?

解决方案 »

  1.   

    嗯 随便反正移动一像素,更改他的MD5值~~
      

  2.   


            /// <summary>
            /// 平移图像
            /// </summary>
            /// <param name="bm"></param>
            /// <param name="nOffset">平移的方向</param>
            /// <param name="nOffset">平移的偏移量</param>
            /// <param name="nOffset">平移的填充像素</param>
            private void Translate(Bitmap bm, Direction Direction, int nOffset, Color crFill)
            {
                switch (Direction)
                {
                    case Direction.Left:
                        {
                            // 向左平移 nDeep 位
                            for (int idxCol = nOffset; idxCol < bm.Width; ++idxCol)
                            {
                                int idxColDst = idxCol - nOffset;                            for (int idxRow = 0; idxRow < bm.Height; ++idxRow)
                                {
                                    Color crSrc = bm.GetPixel(idxCol, idxRow);
                                    bm.SetPixel(idxColDst, idxRow, crSrc);
                                }
                            }
                            // 被移空的地方填充crFill设定的背景
                            FillRect(bm,
                                new Point(bm.Width - nOffset, 0),
                                new Point(bm.Width - 1, bm.Height - 1),
                                crFill);
                        }
                        break;                case Direction.Right:
                        {
                            // 向右平移 
                            for (int idxCol = bm.Width - nOffset - 1; idxCol >= 0; --idxCol)
                            {
                                int idxColDst = idxCol + nOffset;                            for (int idxRow = 0; idxRow < bm.Height; ++idxRow)
                                {
                                    Color crSrc = bm.GetPixel(idxCol, idxRow);
                                    bm.SetPixel(idxColDst, idxRow, crSrc);
                                }
                            }
                            // 填充
                            FillRect(bm,
                                new Point(0, 0),
                                new Point(nOffset - 1, bm.Height - 1),
                                crFill);
                        }
                        break;                case Direction.Down:
                        {
                            // 向下平移 
                            for (int idxRow = bm.Height - nOffset - 1; idxRow >= 0; --idxRow)
                            {
                                int idxRowDst = idxRow + nOffset;                            for (int idxCol = 0; idxCol < bm.Width; ++idxCol)
                                {
                                    Color crSrc = bm.GetPixel(idxCol, idxRow);
                                    bm.SetPixel(idxCol, idxRowDst, crSrc);
                                }
                            }
                            // 填充
                            FillRect(bm,
                                new Point(0, 0),
                                new Point(bm.Width - 1, nOffset - 1),
                                crFill);
                        }
                        break;                case Direction.Up:
                        {
                            // 向上平移 
                            for (int idxRow = nOffset; idxRow < bm.Height; ++idxRow)
                            {
                                int idxRowDst = idxRow - nOffset;                            for (int idxCol = 0; idxCol < bm.Width; ++idxCol)
                                {
                                    Color crSrc = bm.GetPixel(idxCol, idxRow);
                                    bm.SetPixel(idxCol, idxRowDst, crSrc);
                                }
                            }
                            // 填充
                            FillRect(bm,
                                new Point(0, bm.Height - nOffset),
                                new Point(bm.Width - 1, bm.Height - 1),
                                crFill);
                        }
                        break;            }
            }        /// <summary>
            /// 填充矩形
            /// </summary>
            /// <param name="bm">要填充的图像</param>
            /// <param name="ptStart">填充开始位置</param>
            /// <param name="ptEnd">填充结束位置</param>
            /// <param name="ptEnd">填充的像素值</param>
            private void FillRect(Bitmap bm, Point ptStart, Point ptEnd, Color crFill)
            {
                for (int idxCol = ptStart.X; idxCol <= ptEnd.X; ++idxCol)
                {
                    for (int idxRow = ptStart.Y; idxRow <= ptEnd.Y; ++idxRow)
                    {
                        bm.SetPixel(idxCol, idxRow, crFill);
                    }
                }
            }