RichViewEdit,插入图片,Tpicture 读取流错误,请教(200分)

B

bsense

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

bsense

Unregistered / Unconfirmed
GUEST, unregistred user!
自己解决了
 
C

cdj000

Unregistered / Unconfirmed
GUEST, unregistred user!
[:)]错在哪里 ?
 
X

xuegaoyili

Unregistered / Unconfirmed
GUEST, unregistred user!
解决了应说一下办法。。这样自己查也方便 。哈
 
B

bsense

Unregistered / Unconfirmed
GUEST, unregistred user!
错误是,我用tgraphic 保存了数据,又用tpicture.tgraphic 读 ,格式是bmp的,应该使用<br>tpicture.tbitmap 对象 存取,tgraphic 应该是 jpg 格式吧
 
X

xifengge

Unregistered / Unconfirmed
GUEST, unregistred user!
tgraphic不是特指JPG格式的,也可以是TBITMAP格式的啊。<br>反正分也出了,不如散了吧,俺快穷得没分问问题了[:D]
 
B

bsense

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 
顶部