Avaxnet

نسخه کامل: طریقه ی ذخيره و بازيابي تصاوير در بانك اطلاعاتي از نوع پارادوكس در
شما در حال مشاهده نسخه تکمیل نشده می باشید. مشاهده نسخه کامل با قالب بندی مناسب.
function SaveJPEG(dsDestination : TDataSet; Img : TImage; Fld : String) : Integer;
var
   JPEG : TJpegImage;
   BLStream : TBlobStream;
begin
   Jpeg := TJpegImage.Create;
   try
      //Every image should be converted as JPEG
      Jpeg.CompressionQuality := 75;
      Jpeg.Assign(Img.Picture.Graphic);
      BlStream := TBlobStream.Create(dsDestination.FieldByName(Fld) as =
TBLOBField, bmReadWrite);
      Try
         //Saving image...
         Jpeg.SaveToStream(blStream);
         Result := 1;
      finally
         BLStream.Free;
     end;
   finally
      Jpeg.Free;
   end;
end;

function GetJPEG(dsSource : TDataSet; Field : String; var Img : TImage) : Integer;
var
   JPEG : TJpegImage;
   BLStream : TBlobStream;
begin
   Jpeg :=TJPEGImage.Create;
   try
      //If field is not empty, we can proceed with JPEG retrieve
      if not dsIzvor.FieldByName(Polje).isNull then begin
         BLStream :=TBLOBStream.Create(dsSource.FieldByName(Fld) as =
TBLOBField, bmRead);
         try
            BLStream.Position := 0;
            try
            Jpeg.LoadFromStream(BLStream);
               Img.Picture.Assign(JPEG);
            Result := 1;
            except
            end;
         finally
            BLStream.Free;
         end;
      end; //if not isNull
   finally
      Jpeg.Free;
   end;
end;
لینک مرجع