try
            {
                int Height = pictureBox1.Image.Height;
                int Width = pictureBox1.Image.Width;
                Bitmap newbitmap = new Bitmap(pictureBox1.Image);
                Bitmap oldbitmap = (Bitmap)pictureBox1.Image;
                Color pixel;
                for (int x = 1; x < Width; x++)
                {
                    for (int y = 1; y < Height; y++)
                    {
                        int r, g, b;
                        pixel = oldbitmap.GetPixel(x, y);
                        r = 255 - pixel.R;
                        g = 255 - pixel.G;
                        b = 255 - pixel.B;
                        newbitmap.SetPixel(x, y, Color.FromArgb(r, g, b));
                        //newbitmap.LockBits(x, y, Color.FromArgb(r, g, b)); ;
                    }
                }
                this.pictureBox1.Image = newbitmap;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }底片效果,图片显示效果速度慢,希望大神指导,优化下!

解决方案 »

  1.   

    不应该这么做吧,建议看看图像处理。图像中处理可以用提取像素法,指针法,内存法,你用的应该是最慢的提取像素法。
    用内存法:
    Bitmap curbitmap=xxx;//(图片)
                        Rectangle rect=new Rectangle(0,0,curBitmap.Width,curBitmap.Height);
                        System.Drawing.Imaging.BitmapData bmpdata=curBitmap.LockBits(rect,System.Drawing.Imaging.ImageLockMode.ReadWrite,curBitmap.PixelFormat);
                        IntPtr ptr=bmpdata.Scan0;
                        int bytes=curBitmap.Width*curBitmap.Height*3;
                        byte[] RGBValues=new byte[bytes];
                        System.Runtime.InteropServices.Marshal.Copy(ptr,grayValues,0,bytes);
    然后对RGBValues做处理,RGBValues[0],[1],[2],就是一个像素的R,G,B