c# bitmap能转换成不同PixelFormat格式的文件吗

来源:百度知道 编辑:UC知道 时间:2024/06/07 21:08:07
Bitmap bmOld = new Bitmap(strOldFilePath);
int iwidth = bmOld.Width;
int iHeight = bmOld.Height;

Bitmap bmNew = new Bitmap(iwidth, iHeight, PixelFormat.Format16bppRgb565);
Graphics g = Graphics.FromImage(bmNew);
g.DrawImage(bmOld, new Point(0,0));
g.Dispose();
//bmNew.Save(strNewFilePath, ImageFormat.Bmp);

MessageBox.Show(bmOld.PixelFormat.ToString());
MessageBox.Show(bmNew.PixelFormat.ToString());

网上有这种方法,但如果我把新的bitmap保存后,重新打开,再显示它的PixelFormat,则会变成Format32rgb了.

http://hi.baidu.com/jonnysuen/blog/item/1ec9ddff38ca2e385d600852.html

分享]一个图片转换类,比如PNGtoJPG,BMPtoPNG按比例缩小图片