在C#上将raw文件转换为bmp文件,并保存
比如说文件在D:\123.raw,要求保存路径可以通过弹出窗口极性选择,然后保存成bmp文件格式急求,在线等,能解决问题再加分...
比如说文件在D:\123.raw,要求保存路径可以通过弹出窗口极性选择,然后保存成bmp文件格式
急求,在线等,能解决问题再加分 展开
急求,在线等,能解决问题再加分 展开
1个回答
展开全部
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; /* new way */
graphic.DrawImage(original_image, paste_x, paste_y, new_width, new_height);
final_image.Save(strPath + strNewFileName, System.Drawing.Imaging.ImageFormat.Bmp);
///////////////////////////////////////////
思路就是读取到文件流中,然后按照mageFormat.Bmp重新保存
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; /* new way */
graphic.DrawImage(original_image, paste_x, paste_y, new_width, new_height);
final_image.Save(strPath + strNewFileName, System.Drawing.Imaging.ImageFormat.Bmp);
///////////////////////////////////////////
思路就是读取到文件流中,然后按照mageFormat.Bmp重新保存
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询