作者ONLYSMART ()
看板C_Sharp
标题[问题] GDI+ 泛型错误?
时间Tue Jun 7 17:51:20 2011
本来的回圈,可以不会出错
foreach (PictureBox p_pb in flowLayoutPanel1.Controls)
{
byte[] buf;
MemoryStream ms = new MemoryStream();
p_pb.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
buf = ms.GetBuffer();
l_cp.产品编号 = lv_strGetMaxPrID
l_cp.照片 = buf;
ClsPicturesFactory l_cpifactory = new ClsPicturesFactory();
l_cpifactory.create(l_cp);
}
改用WPF的控制项,就会出现GDI+ 泛型错误
foreach (ElementHost p_eh in flowLayoutPanel1.Controls)
{
byte[] buf;
PictureBox p = new PictureBox();
var source =
((System.Windows.Controls.Image)((UserControl1)p_eh.Child).FindName("Image2"))
.Source;
p.Load(source.ToString());
MemoryStream ms = new MemoryStream();
p.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);//这行会出错
buf = ms.GetBuffer();
l_cp.产品编号 = lv_strGetMaxPrID;
l_cp.照片 = buf;
ClsPicturesFactory l_cpifactory = new ClsPicturesFactory();
l_cpifactory.create(l_cp);
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.32.9.209
※ 编辑: ONLYSMART 来自: 114.32.9.209 (06/07 18:09)
1F:→ optimist9266:你的source.ToString()应该不是你想像中的图片档名称 06/07 18:36
2F:→ optimist9266:我记得Image控制项会把你给他的文字档路径解码成 06/07 18:36
3F:→ optimist9266:ImageSource执行个体 06/07 18:36
大大!请问要则麽改?那个是档案路径没错!监看式有跑出来!
※ 编辑: ONLYSMART 来自: 114.32.9.209 (06/07 18:46)
※ 编辑: ONLYSMART 来自: 114.32.9.209 (06/07 19:42)