哪位大哥帮帮忙!分数不够小弟愿再加,谢谢啦!!

解决方案 »

  1.   

    导入图片,我没有上机验证,不知对不对
    procedure TForm1.ImportPicture(APath:string); //路径参数必须带有'\'字符
    var
      SR:TSearchRec;
      found:integer;
      ext:string;
    begin
      found:=FindFirst(Pchar(APath+'*.*'),faAnyFile,SR);
      while found=0 do
      begin
        //获取搜索到的文件扩展名
        ext:=LowerCase(ExtractFileExt(SR.Name);
        //判断是否图像
        if (ext='.bmp') or (ext='.jpeg') or (ext='.jpg') or (ext='.ico') then
        begin
          Table1.Append;  //增加一条记录
          Table1.FieldByName('Name').AsString:=SR.Name;
          TBlobField(Table1.FieldByName('bmp')).LoadFromFile(APath+SR.Name);
          Table1.Post;
        end;
        //搜索子目录,如果你想的话
        if (SR.Attr=faDirectory) and (SR.Name<>'.') and (SR.Name<>'..') then
          ImportPicture(APath+SR.Name+'\'); //递归调用这个函数
        found:=FindNext(SR);
      end; 
      FindClose(SR);
    end;//导出图像
    procedue TForm1.ExportPicture;
    var
      Path,FN:string;
    begin
      if SelectDirectory('请选择导出目录','',Path) then
      begin
        if Path[Length(Path)]<>'\' then
          Path:=Path+'\';
        Table1.First;
        while not Table1.Eof do
        begin
          FN:=Path+Table1.FieldByName('Name').AsString;
          TBlobField(Table1.FieldByName('bmp')).SaveToFile(FN);
          Table1.Next;
        end;
      end;
    end;
    如果有问题请联系 [email protected]
    欢迎光临我的主页 http://rainbowstudio.126.com