我计划把JPG图片存入Access中,怎么限制要存入数据库图片的大小,比如:我只想让12*12大小以下的图片存入,我该如何判断当前用户选中的图片是否符合这个标准??

解决方案 »

  1.   

    哈哈找到了
    把jpg的图片存到access中的ole对象类型的字段中
          try
            pt:=TMemoryStream.Create;
            Image1.Picture.Graphic.SaveToStream(pt);
            TBlobField(ADOQuery1.FieldByName('Picture')).LoadFromStream(pt);
          finally
            pt.Free;
          end;
    通过判断image1.picture.width和image1.picture.height就可以限制存入图片的分辨率大小了。
      

  2.   

    var
      JPEG:TJPEGImage;
    begin
          JPEG:=TJPEGImage.Create;
          JPEG.LoadFromFile('your file name');
          if (JPEG.Height>12) or (JPEG.Width>12) then
            showmessage('图片超过限制');
          JPEG.Free;
    end;
      

  3.   

    pt.size
    加载时判断就可以了。
      

  4.   

    var
       f: file of Byte;
       size: Longint;
    begin
        AssignFile(f, 'your file name');
        Reset(f);
        try
          size := FileSize(f);
          if size>1024 then
            showmessage('图片超过1024字节');
        finally
          CloseFile(f);
        end;
    end;
      

  5.   

    用FileSize()方法图片属性必须不是只读的
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject); //BUTTON触发,以KB为单位的
    var
      iFileHandle: Integer;
      iFileLength: Single;
      i          : integer;
    begin
      if OpenDialog1.Execute then
      begin
          iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
          iFileLength := FileSeek(iFileHandle,0,2) / 1024;
          i           := FileSeek(iFileHandle,0,2) div 1024;
          if (iFileLength-i) > 0 then
          i:= i+1;
          edit1.Text := inttostr(i);
          FileClose(iFileHandle);  end;
    end;