永发信息网

在C#上将raw文件转换为bmp文件,并保存

答案:1  悬赏:30  手机版
解决时间 2021-11-17 07:59
  • 提问者网友:两耳就是菩提
  • 2021-11-16 12:05
在C#上将raw文件转换为bmp文件,并保存
最佳答案
  • 五星知识达人网友:山有枢
  • 2021-11-16 13:24
System.Drawing.Image original_image = null;
System.Drawing.Bitmap final_image = null;
System.Drawing.Graphics graphic = null;

original_image = System.Drawing.Image.FromStream(jpeg_image_upload.InputStream);
final_image = new System.Drawing.Bitmap(target_width, target_height);
graphic = System.Drawing.Graphics.FromImage(final_image);

graphic.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.Rectangle(0, 0, target_width, target_height));
int paste_x = (target_width - new_width) / 2;
int paste_y = (target_height - new_height) / 2;

graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

graphic.DrawImage(original_image, paste_x, paste_y, new_width, new_height);

final_image.Save(strPath + strNewFileName, System.Drawing.Imaging.ImageFormat.Bmp);

///////////////////////////////////////////
思路就是读取到文件流中,然后按照mageFormat.Bmp重新保存
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯