| 发表于:2007-06-30 10:34:43 楼主 |
我用一个函数来处理打开图像,如下: function openpictre(width,height:integer):tstream; var opendialog:topenpicturedialog; image:timage; jpg:tjpegimage; bmp:tbitmap; r:real; stream:tmemorystream; begin stream:=tmemorystream.create; result:=stream; opendialog:=topenpicturedialog.create(nil); try if opendialog.EXECute then begin image:=timage.create(nil); image.autosize:=true; image.picture.loadfromfile(opendialog.filename); if (image.width> 0) and (image.height> 0) then r:=getiffvalue(width/image.width> height/image.height,height/image.height,width/image.width); bmp:=tbitmap.create; jpg:=tjpegimage.create; try bmp.width:=trunc(image.width*r); bmp.height:=trunc(image.height*r); bmp.canvas.stretchdraw(bmp.canvas.cliprect,image.picture.graphic); jpg.assign(bmp); jpg.savetostream(stream); result:=stream; finally image.free; bmp.free; jpg.free; end; end; finally opendialog.free; end; end; 然后用双击事件打开代码如下: procedure tbbboxexpr_frm.boximagedblclick(sender: tobject); var tabtemp:tadocommand; begin inherited; begin tblobfield(tabmaster.fieldbyname( 'boximage ')).loadfromstream(getpicture(500,300)); tabtemp:=tadocommand.create(nil); try tabtemp.connection:=sbdatamode.adoconnection; tabtemp.commandtext:= 'delete tbb_boxmark where boxid= '+quotedstr(tabmasterboxid.asstring); tabtemp.EXECute; finally tabtemp.free; end; end; end; 但程序运行时提示 "bitmap image is not valid "这是什么原因? |
|
|
|
|