(tip_修订0618)bmp 32位转24位

没什么效率可言,完全是解决问题,

            Bitmap bmp = new Bitmap(320240, PixelFormat.Format24bppRgb);
            Bitmap bmp1 
= new Bitmap("c:\\aa.bmp");
            
for (int i = 1; i < 240; i++)
            
{
                
for (int j; j < 320; j++)
                
{
                    bmp.SetPixel(j,i,bmp.GetPixel(j,i);                
                }
            
            }


           bmp.Save(
"d:\\cc.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
找到新的方法,感谢csdn网友------------->http://topic.csdn.net/t/20050226/10/3807935.html
way 1:
1             Bitmap bmp1 = new Bitmap("c:\\aa.bmp");            
2             BitmapData bd = bmp1.LockBits(new Rectangle(0,0,bmp1.Width,bmp1.Height),ImageLockMode.ReadOnly,PixelFormat.Format24bppRgb);
3             Bitmap bmp = new Bitmap(bmp1.Width, bmp1.Height,bd.Stride,bd.PixelFormat, bd.Scan0);
4             bmp.Save("d:\\mm.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5             bmp1.UnlockBits(bd);
way 2:
1            Bitmap bmp1 = new Bitmap("c:\\aa.bmp");
2            BitmapData bd = bmp1.LockBits(new Rectangle(00, bmp1.Width, bmp1.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
3            Bitmap bmp = bmp1.Clone(new Rectangle(00, bmp1.Width, bmp1.Height), bd.PixelFormat);
4            bmp.Save("d:\\hh.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5            bmp1.UnlockBits(bd);

bmp资源自行处理..........
posted @ 2008-06-10 17:21  markmars  阅读(...)  评论(...编辑  收藏