Board index » delphi » "bitmap image is not valid"????????????

"bitmap image is not valid"????????????

Hello, there

When I tried to extract a picture from MS-access database by ADO
data-ware component, I got "
bitmap image is not valid" error message.

Is there anyone can help me to fix it?

Thanks very much

Best Regards
QTL

 

Re:"bitmap image is not valid"????????????


From my book:

Bitmap image is not valid
Possible Cause of Error
1. You may be loading a file into a TImage's Picture property that, although
it has a .BMP extension, is not in actuality a .BMP file.
The .BMP file may be corrupt.
2. There may be a mismatch between the bitmap and the PixelFormat property
of the Picture object's Bitmap property.
3. You may be attempting to load a graphic BLOb into MS Access, MS SQL
Server, or MS Fox Pro into a TDBImage component.

Quick Fix
1. Ensure that any file you attempt to load into a TImage component's
Picture property is indeed a valid graphics file.
2. Change the value of the Picture.Bitmap.PixelFormat property.
3. Put the following in the dataset's AfterScroll event:

procedure TWhatever.<DatasetName>AfterScroll(Dataset:
                          TDataset);
const
  LENGTH_OF_HEADER_INFO = 78;
var
  bm: TBitmap;
  bs: TBLObStream;
begin
  bx := TBLObStream.Create(<TFieldName>, bmRead);
  try
    bs.Seek(LENGTH_OF_HEADER_INFO, soFromBeginning);
    bm := Tbitmap.Create;
    try
      bm.LoadFromStream(bs);
      DBImage.Picture.Graphic := bm;
    finally
      bm.Free;
    end;
  finally
    bs.Free;
  end;
end;

Additional Information
3. The Microsoft databases mentioned store graphics as OLE objects rather
than as raw data. NOTE: <TfieldName> is a concatenation of Dataset name and
Field name.
Delphi provides native support for four graphic file formats, namely .BMP
(bitmap), .ICO (icon), .WMF (Windows MetaFile), and .EMF (Enhanced
MetaFile).
It may be that somebody changed a file's extension so that it appears to be
a bitmap file based on its file extension (but it is not in actuality a
bitmap file).

--

Clay Shannon, author of "Tomes of Delphi: Developer's Guide to
Troubleshooting" and the novels
"Twisted Roads" (which features a Delphi developer), "The Vavilovian
{*word*97}" and "The Resurrection of Samuel Clemens"
(see
http://www.greatunpublished.com/bookstore/author.php3?accountID=GRTU0...)
or
search on my name or a book title at www.amazon.com

Quote
"QTL" <szaet...@ihug.co.nz> wrote in message

news:3CC2BDE0.5080106@ihug.co.nz...
Quote
> Hello, there

> When I tried to extract a picture from MS-access database by ADO
> data-ware component, I got "
> bitmap image is not valid" error message.

> Is there anyone can help me to fix it?

> Thanks very much

> Best Regards
> QTL

Other Threads