title: DBImage with bitmap?
body: <p>I am currently trying to read an Image from a MS Access database that has an OLE Object field and contains a valid bitmap (for test purposes, I created a image using MS Paint and saved it in 24bit bmp).</p>
  
  <p>I am linking to this via DBGrid. In theory everything should work good and it should show the image, however I am getting a: "bitmap image not valid" error. I can understand if this is a JPEG and not .bmp, but that isn't the case. So my question is, what is wrong?</p>
  
  <p>I dont necessarily have to use a DBImage, a normal TImage will also do just fine (might even be more preferable), but I'm not sure on how to assign a TImage to an OLE Object field in a MS Access Database. I Have tried, to no avail:</p>
  
  <pre><code>//Select photo from Image field  
  Image1.Picture := ADOTable1['Image'];
  </code></pre>
  
  <p>I've read most of the articles, such as about.com etc, regarding this matter, but still don't get any good results.</p>
  
  <p>Any help would be greatly appreciated! </p>
  
  <p>UPDATE: This worked for me:</p>
  
  <p><em>Add to USES clause : JPEG, ADODB, DB</em></p>
  
  <pre><code>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 &lt; 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; 
  end; 
  finally
  bS.Free
  end;  
  end;
  
  procedure TfrmOne.btnShowImageClick(Sender: TObject);
  var
   bS : TADOBlobStream;
   Pic : TJPEGImage;
  begin
  
  bS := TADOBlobStream.Create(table1.FieldByName('Photo') as TBlobField, bmRead);   
  bS.Seek(JpegStartsInBlob(table1.FieldByName('Photo') as TBlobField),
          soFromBeginning);
  Pic := TJPEGImage.Create;
  Pic.LoadFromStream(bS);
  frmOne.Image1.Picture.Graphic := Pic;
  Pic.Free;
  bS.Free;
  end;
  </code></pre>