如何用DELPHI 从ACCESS库中提取图象?

解决方案 »

  1.   

    我用的是ADO控件连接。首先在access数据库中建立一个含有位图地字段,然后利用简帖板的图像拷贝的功能,首先进行图像格式的转换,在利用数据库操作的函数完成。给你部分主要代码看看:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if OpenPictureDialog1.Execute then
      begin
        try
        Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
        except
        Application.MessageBox('文件类型错误','错误',MB_OK);//?????
        end;
        if not (Image1.Picture.Graphic Is TBitmap) then
        begin
          ClipBoard.Assign(Image1.Picture);
          Image1.Picture.Bitmap.Assign(ClipBoard);
          ClipBoard.Clear;    end;//Change the picture that's not belonged to .bmp to .bmp
           // picture
        ADOTable1.Edit;
        ADOTable1.FieldByName('pic').Assign(Image1.Picture);
        ADOTable1.Post;
        image1.Picture.Bitmap.Assign(nil);
        //get from database
        //Image1.Picture.Bitmap.Assign(TPicture(Table1.FieldByName('Image')));
      end;
    end;