回 帖 发 新 帖 刷新版面

主题:储存图片问题?

请教各位大虾:
delphi+sqlserver
如何储存jpg 格式的图片,图片大小有限制吗?
谢谢!

回复列表 (共3个回复)

沙发

1、TBlobField(FieldByName('Photo')).LoadFromStream(PhotoData.Data);
2、with TADOBlobStream.Create(TBlobField(FieldByName('Photo')),bmWrite) do
   try
     LoadFromStream(PhotoData.Data);
   finally
     Free;
   end;

板凳

谢谢dodolon的答复,请问有更详细一点的吗?

3 楼

这是我开发的考勤软件中员工信息编辑对话框中更新员工信息的一段代码:
      with DataSet do
        begin
          Edit;
          try
            SetEmployeeData(DataSet,PEI,True); //将PEI指向记录中员工信息写入记录
            if Assigned(Self.EmployeeInfoFrame1.Image_Photo.Picture.Graphic) then  //Image控件中有相片
              begin
                PhotoData.Data.Clear;
                if Self.EmployeeInfoFrame1.Image_Photo.Picture.Graphic is TBitMap then
                    BmpToJpeg(EmployeeInfoFrame1.Image_Photo.Picture.Bitmap,
                              PhotoData.Data,
                              GetOptionInteger('PhotoQuality'),
                              GetOptionBool('PhotoGrayscale'))
                else
                  Self.EmployeeInfoFrame1.Image_Photo.Picture.Graphic.SaveToStream(PhotoData.Data);
                TBlobField(FieldByName('Photo')).LoadFromStream(PhotoData.Data);
                {with TADOBlobStream.Create(TBlobField(FieldByName('Photo')),bmWrite) do
                  try
                    LoadFromStream(PhotoData.Data);
                  finally
                    Free;
                  end; }
              end
            else
              FieldByName('Photo').Clear;
            Post;
            Result:=True;
          except
            Result:=False;
          end;
        end;
其中:
  PEmployeeInfo = ^TEmployeeInfo;
  TEmployeeInfo = record
    EmployeeID     : Integer;
    Number         : String[10];
    Code           : String[4];
    Name           : String[20];
    Sex             : String[2];
    HoldCardInfo : TCardHoldInfo;
    BusinessInfo : TBusinessInfo;
    IdentityCard : String[19];
    Accounts       : String[10];
    Password       : String[20];
    Phone           : String[15];
    WorkPhone       : String[15];
    HandPhone       : String[15];
    Address           : String[100];
    Postalcode     : String[10];
    E_mail           : String[40];
  end;

   PhotoData: TrmBinaryDataStorage; //PhotoData.Data是TMemoryStream;


我来回复

您尚未登录,请登录后再回复。点此登录或注册