Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PLEEEEESE help, bitmap problems

1 view
Skip to first unread message

Tim

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
Hi,

I'm trying to read a bitmap image from an OLE field in Access. The image was
inserted in that field by Access proper. But when I try and read it using
the following:-

Graphics::TBitmap *Bitmap = new Graphics::TBitmap();

//Check to see if field is populated
if (Table1Background->IsNull == false)
{
Bitmap->Assign(Table1->FieldByName("Background"));
Image1->Canvas->Draw(0,0,Bitmap);
}

delete Bitmap;

I get an "Bitmap image is not valid" error message.

I get the same problem if I try and use a TDBImage component too!

Any ideas?

Desparate.

Tim


Harold Howe (TeamB)

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to

Tim wrote in message <7r881h$5l...@forums.borland.com>...

>Hi,
>
>I'm trying to read a bitmap image from an OLE field in Access. The image
was
>inserted in that field by Access proper. But when I try and read it using
>the following:-
>
>I get an "Bitmap image is not valid" error message.
>


An embedded OLE image is not a bitmap. Its a bitmap with some an OLE header
prepended to it. You can't put the binary image of an OLE embedded image
into a bitmap and expect it to work. Here is some info that I posted a while
back.

-------------------------------------------------------------


I ran into this about 3 months ago. The problem is that an OLE image
contains a header in front of the image. What you need to do is rip out that
header and put whats left into an image control. Ideally you would read the
header, but I never figured out how to do that.

By searching dejanews, I was able to determine that the OLE header was 78
bytes. So, I read the blob field, yank out those 78 useless bytes that just
get in the way, and then put the rest of the data from the field into an
image. Here is the code that I used.


void __fastcall TForm1::Button7Click(TObject *Sender)
{
// Table2image_field is the name of the blob field for the image
TBlobStream *blob = new TBlobStream(Table2image_field,bmRead);
TMemoryStream *mem = new TMemoryStream;

// 4E is 78 in hex. Advance the blob stream position past the OLE
// header. Then copy the rest of the blob stream into a memory
// stream. Then copy the mem stream into an image.
blob->Position = 0x4E;
mem->Size = blob->Size - 0x4E;
blob->Read(mem->Memory, mem->Size);
Image2->Picture->Bitmap->LoadFromStream(mem);
delete mem;
delete blob;
}

One would think that you could actually use the OLE header to launch the OLE
associated program and activate that program in place. My mental capacity
was not capable of accomplishing that task.

</hacking>

Harold Howe [TeamB]
http://www.bcbdev.com

Tim

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to
>An embedded OLE image is not a bitmap. Its a bitmap with some an OLE header
>prepended to it. You can't put the binary image of an OLE embedded image
>into a bitmap and expect it to work. Here is some info that I posted a
while
>back.
<snip, good stuff>

Hi Harold

Bit confusing this. I'm already storing an array of binary data in an OLE
field and that, quite obviously, isn't preceeded by a header. Presumably MS
only put that header in front of the bitmap "file"?

MS off doing weird things again? Did you know that a bitmap is stored upside
down?

BTW how do you write a bitmap into an OLE field from C Builder?

Thanx (and relieved)

Tim

Harold Howe (TeamB)

unread,
Sep 9, 1999, 3:00:00 AM9/9/99
to

Tim wrote in message <7r8eas$5k...@forums.borland.com>...

>BTW how do you write a bitmap into an OLE field from C Builder?


I never got that far. I don't have a clue.

Tim

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
Hi Harold.

Got the reading bit ok. I'll try the writing bit today. Thanx v'much.

Tim

0 new messages