在c#中将原始图像转换为位图
发布时间:2020-12-16 01:56:22 所属栏目:百科 来源:网络整理
导读:我的代码目前看起来像这样: if (fe == "CR2"){ Image img = null; byte[] ba = File.ReadAllBytes(open.FileName); using (Image raw = Image.FromStream(new MemoryStream(ba))) { img = raw; } Bitmap bm = new Bitmap(img); pictureBox1.Image = bm; sta
我的代码目前看起来像这样:
if (fe == "CR2") { Image img = null; byte[] ba = File.ReadAllBytes(open.FileName); using (Image raw = Image.FromStream(new MemoryStream(ba))) { img = raw; } Bitmap bm = new Bitmap(img); pictureBox1.Image = bm; statusl.Text = fe; } 当我打开RAW图像时程序停止,Visual Studio说:
请帮忙!如何在PictureBox中显示RAW文件? 解决方法
像这样创建位图:
Bitmap bmp = (Bitmap) Image.FromFile(open.FileName); 或不使用位图: this.pictureBox1.Image = Image.FromFile(open.FileName); 示例WPF: BitmapDecoder bmpDec = BitmapDecoder.Create(new Uri(origFile),BitmapCreateOptions.DelayCreation,BitmapCacheOption.None); BitmapEncoder bmpEnc = new BmpBitmapEncoder(); bmpEnc.Frames.Add(bmpDec.Frames[0]); Stream ms = new MemoryStream(); bmpEnc.Save(ms); Image srcImage = Bitmap.FromStream(ms); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |