B
bsense
Unregistered / Unconfirmed
GUEST, unregistred user!
//这个代码是 从一个数据库字段image类型读取 数据-->stream<br>//再加载到 picture ,再复制到一个richviewedit 的graphics 对象<br>//如下,那句出错,请教大家怎么改<br><br>procedure Tfrm_DetectPlan.N1Click(Sender: TObject);<br>var s: string;<br> itemno: integer;<br> offs: integer;<br> gr: TGraphic;<br> pic: TPicture;<br> stream:tmemorystream;<br>begin<br> inherited;<br> //定位到最前面<br><br> s := '方案编制:'; // 室主任: 技术负责人:<br> ItemNo := 0;<br> Offs := RichViewEdit1.GetOffsBeforeItem(ItemNo);<br> RichViewEdit1.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);<br> //找到字符<br> if RichViewEdit1.SearchText(s, [rvseoDown]) then<br> begin<br> //RichViewEdit1.InsertTextW(StrToWideString(d), False);<br> //定位到后面<br> richviewedit1.GetOffsBeforeItem(richviewedit1.CurItemNo);<br> Offs := RichViewEdit1.GetOffsBeforeItem(ItemNo);<br> RichViewEdit1.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);<br> //插入图片<br> //RichViewEdit1.InsertPicture('fanganbianzhi', image1.Picture.Graphic, rvvaBaseline);<br> end;<br><br> zqry1.Close;<br> zqry1.SQL.Clear;<br> zqry1.SQL.add('select userid,userhand from users where users.userid='''+user.UserId + '''');<br> zqry1.Open;<br><br> pic := TPicture.Create;<br> stream := tmemorystream.create;<br> {$message '图片无法正常读取,什么问题'}<br> try<br> TblobField(zqry1.FieldByName('userhand')).SaveToStream(stream);<br> if assigned(stream) then<br> begin<br> stream.Position := 0;<br> if stream.Size > 10 then //容错<br> begin<br> pic.Graphic.LoadFromStream(stream); //这句子出错<br> gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));<br> gr.Assign(pic.Graphic);<br> RichViewEdit1.InsertPicture(user.UserId, gr, rvvaBaseline);<br> end;<br> end;<br> finally<br> pic.Free;<br> stream.Free;<br> end;