-   
- unit database; 
-   
- interface 
-   
- uses 
-   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
-   Dialogs, StdCtrls, ExtCtrls, DB, ADODB, Grids, DBGrids; 
-   
- type 
-   TForm1 = class(TForm) 
-     DBGrid1: TDBGrid; 
-     ADOTable1: TADOTable; 
-     DataSource1: TDataSource; 
-     ADOConnection1: TADOConnection; 
-     ADOimage: TImage; 
-     Button1: TButton; 
-     procedure Button1Click(Sender: TObject); 
-   private 
-     { Private declarations } 
-   public 
-     { Public declarations } 
-   end; 
-   
- var 
-   Form1: TForm1; 
-   
- implementation 
-  uses jpeg; 
- {$R *.dfm} 
-   
- function JpegStartsInBlob 
-          (PicField:TBlobField):integer; 
- var 
-  bS     : TADOBlobStream; 
-  buffer : Word; 
-  hx     : string; 
- begin 
-  Result := -1; 
-  bS := TADOBlobStream.Create(PicField, bmRead); 
-  try 
-   while (Result = -1) and 
-         (bS.Position + 1 < bS.Size) do 
-   begin 
-    bS.ReadBuffer(buffer, 1); 
-    hx:=IntToHex(buffer, 2); 
-    if hx = 'FF' then begin 
-      bS.ReadBuffer(buffer, 1); 
-      hx:=IntToHex(buffer, 2); 
-      if hx = 'D8' then Result := bS.Position - 2 
-      else if hx = 'FF' then 
-         bS.Position := bS.Position-1; 
-    end; //if 
-   end; //while 
-  finally 
-   bS.Free 
-  end;  //try 
- end; 
-   
-   
- procedure TForm1.Button1Click(Sender: TObject); 
- var 
-   bS  : TADOBlobStream; 
-   Pic : TJpegImage; 
- begin 
-   bS := TADOBlobStream.Create 
-         (AdoTable1Picture, bmRead); 
-   try 
-     bS.Seek(JpegStartsInBlob(AdoTable1Picture), 
-             soFromBeginning); 
-     Pic:=TJpegImage.Create; 
-     try 
-      Pic.LoadFromStream(bS); 
-      ADOImage.Picture.Graphic:=Pic; 
-     finally 
-      Pic.Free; 
-     end; 
-   finally 
-     bS.Free 
-   end; 
- end; 
-