您的位置:程序门 -> delphi -> 数据库相关



为什么打开图像时提示"bitmap image is not valid"


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


为什么打开图像时提示"bitmap image is not valid"[无满意答案结贴,结贴人:liao71]
发表于: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 "这是什么原因?
发表于:2007-06-30 14:02:111楼 得分:0
getpicture?openpictre?到底是哪个函数在工作?
openpictre里面明明是返回jpeg流,不是bmp流
发表于:2007-06-30 14:06:072楼 得分:0
刚才写错了。是openpicture
procedure   tbbboxexpr_frm.boximagedblclick(sender:   tobject);
var
tabtemp:tadocommand;
begin
    inherited;
        begin
          tblobfield(tabmaster.fieldbyname( 'boximage ')).loadfromstream(openpicture(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 "  
发表于:2007-07-02 16:44:253楼 得分:0
openpictre里面是返回jpeg流,不是bmp流
发表于:2007-07-02 22:53:504楼 得分:0
要怎么处理才行.
发表于:2007-11-27 10:33:235楼 得分:0
储存入数据库的数据有问题.
发表于:2007-11-27 10:53:126楼 得分:0
请你使用 <*.bmp> 文件


快速检索

最新资讯
热门点击