Technical Information Database TI791D.txt Extracting A Bitmap From A BLOB Field Category :Database Programming Platform :All Product :Delphi All Description: Extracting a bitmap from a dBASE or Paradox blob field -- without first saving the bitmap out to a file -- is a simple process of using the Assign method to store the contents of the BLOB field to an object of type TBitmap. A stand-alone TBitmap object or the Bitmap property of the Picture object property of a TIMage component are examples of compatible destinations for this operation. Here is an example demonstrating using the Assign method to copy a bitmap from a BLOB field into a TImage component. procedure TForm1.Button1Click(Sender: TObject); begin Image1.Picture.Bitmap.Assign(Table1Bitmap); end; In this example, the TBLOBField object Table1Bitmap is a BLOB field in a dBASE table. This TBLOBField object was created using the Fields Editor. If the Fields Editor is not used to create TFields for the fields in the table, the fields must be referenced using either the FieldByName method or the Fields property, both part of the TTable and TQuery components. In cases where one of those means is used to reference the BLOB field in a table, the field reference must be type-cast as a TBLOBField object prior to using the Assign method. For example: procedure TForm1.Button1Click(Sender: TObject); begin Image1.Picture.Bitmap.Assign(TBLOBField(Table1.Fields[1])); end; A bitmap stored in a BLOB field may also be copied directly to a stand- alone TBitmap object. Here is an example showing the creation of a TBitmap object and storing into it a bitmap from a BLOB field. procedure TForm1.Button2Click(Sender: TObject); var B: TBitmap; begin B := TBitmap.Create; try B.Assign(Table1Bitmap); Image1.Picture.Bitmap.Assign(B); finally B.Free; end; end; Reference: 7/16/98 4:33:54 PM
Article originally contributed by