15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Creating Bitmap from DaoRecordSet field.

George Kostas Grous -- georgeg@btc.adaptec.com
Wednesday, March 05, 1997


Environment: MSVC 4.2b, Windows 95, Access

Greetings:

I have an access database in which 1 field is defined as an OLE Object. I
manually added bitmaps to this field using access (size 16x16 - 16 =
colors).

I created a DaoRecordSet, bound to this OLE Object column and the =
variable for
the DFX call is declared as CByteArray() (as MS suggested instead of
CLongBinary).

When the object is retrieved its size is 346 bytes (Shouln't it be 16*16 =
or 256
?) . I tried creating the bitmap by doing the following:

...
CBitmap* pBitmap =3D new CBitmap();
pBitmap->CreateBitmap(16, 16, 16, recordset->bData.GetSize(),
&recordset->bData.GetAt(0));
...

When I attempt to display the image as an icon in a tree it is garbage.

How do you extract binary data from a field in an Access database ? Is =
there a
special procedure that I am missing ?  How do you add binary data to the =
db ?
I have tried a lot of methods, and nothing worked. Pointers to sample =
code or
any suggestions are greatly appreciated.

Thanks in advance.
Best regards,

George Kostas Grous

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzIu9MoAAAEEAL2T3tiBic7wrvE3cxvvzQzMEdfS1EoJVPX7JmVPzpwHH0n4
HQEuRSmemEHfDREWcInjHJfVJamTXxcR+NC1Lvlj/uB+F7ElJxJ3AwotDm9EOP/W
bQxc3WqEd9MrGa0zkpfcny5pE9WAE4sHS5O6DdyIuxxwBfAQMmXBGQ44h8QFAAUR
tCZHZW9yZ2UgS29zdGFzIEdyb3VzIChnZW9yZ2VnQHJtaWkuY29tKQ=3D=3D
=3DLztD
-----END PGP PUBLIC KEY BLOCK-----



Kefah Ibrahim -- KIbrahim_Ideal@nets.com.jo
Thursday, March 06, 1997

[Mini-digest: 2 responses]

Hi 
I've answered the same questions few weeks ago, following is my answer.

Bitmap are considered Binary data, and DAO needs data to be in COleVariant to
be inserted.
Now, what you need is how to convert binary data( Bitmap) to COleVariant and
vice versa.
There is a very helpful Microsoft KBase article that has the title" How to
access Binary data using dbDoa" (PSS ID #: Q152294) under the ( C Compiler )
topics.
And because you are working on Win95 (32-bit) you need to modify the line
that use memcpy to be CopyMemory and this is the 32-bit version of memcpy !!!

Good luck,

Kefah Jizmawi
e-mail: KIbrahim_Ideal@nets.com.jo


mfc-l@netcom.com,Internet writes:

Environment: MSVC 4.2b, Windows 95, Access

Greetings:

I have an access database in which 1 field is defined as an OLE Object. I
manually added bitmaps to this field using access (size 16x16 - 16 =
colors).

I created a DaoRecordSet, bound to this OLE Object column and the =
variable for
the DFX call is declared as CByteArray() (as MS suggested instead of
CLongBinary).

When the object is retrieved its size is 346 bytes (Shouln't it be 16*16 =
or 256
?) . I tried creating the bitmap by doing the following:

...
CBitmap* pBitmap =3D new CBitmap();
pBitmap->CreateBitmap(16, 16, 16, recordset->bData.GetSize(),
&recordset->bData.GetAt(0));
...

When I attempt to display the image as an icon in a tree it is garbage.

How do you extract binary data from a field in an Access database ? Is =
there a
special procedure that I am missing ?  How do you add binary data to the =
db ?
I have tried a lot of methods, and nothing worked. Pointers to sample =
code or
any suggestions are greatly appreciated.

Thanks in advance.
Best regards,

George Kostas Grous

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzIu9MoAAAEEAL2T3tiBic7wrvE3cxvvzQzMEdfS1EoJVPX7JmVPzpwHH0n4
HQEuRSmemEHfDREWcInjHJfVJamTXxcR+NC1Lvlj/uB+F7ElJxJ3AwotDm9EOP/W
bQxc3WqEd9MrGa0zkpfcny5pE9WAE4sHS5O6DdyIuxxwBfAQMmXBGQ44h8QFAAUR
tCZHZW9yZ2UgS29zdGFzIEdyb3VzIChnZW9yZ2VnQHJtaWkuY29tKQ=3D=3D
=3DLztD
-----END PGP PUBLIC KEY BLOCK-----


-----From: "Wu, Leo                     PL" 


Hi! George ,

The size of a bitmap is the size of a header + the sizeof bits(16x16 in this 
case)
the header comes first.

For the structure of header, look for BITMAPINFOHEADER in the VC document

Regards,

Leo Wu.


 ----------
|From: georgeg@btc.adaptec.com
|To: mfc-l@netcom.com
|Subject: Creating Bitmap from DaoRecordSet field.
|Date: Wednesday, March 05, 1997 3:52PM
|
|
|
|Environment: MSVC 4.2b, Windows 95, Access
|
|Greetings:
|
|I have an access database in which 1 field is defined as an OLE Object. I
|manually added bitmaps to this field using access (size 16x16 - 16 colors).
|
|I created a DaoRecordSet, bound to this OLE Object column and the variable
|for
|the DFX call is declared as CByteArray() (as MS suggested instead of
|CLongBinary).
|
|When the object is retrieved its size is 346 bytes (Shouln't it be 16*16 or
|256
|?) . I tried creating the bitmap by doing the following:
|
|...
|CBitmap* pBitmap = new CBitmap();
|pBitmap->CreateBitmap(16, 16, 16, recordset->bData.GetSize(),
|&recordset->bData.GetAt(0));
|...
|
|When I attempt to display the image as an icon in a tree it is garbage.
|
|How do you extract binary data from a field in an Access database ? Is
|there a
|special procedure that I am missing ?  How do you add binary data to the db
|?
|I have tried a lot of methods, and nothing worked. Pointers to sample code
|or
|any suggestions are greatly appreciated.
|
|Thanks in advance.
|Best regards,
|
|George Kostas Grous
|
| -----BEGIN PGP PUBLIC KEY BLOCK-----
|Version: 2.6.2
|
|mQCNAzIu9MoAAAEEAL2T3tiBic7wrvE3cxvvzQzMEdfS1EoJVPX7JmVPzpwHH0n4
|HQEuRSmemEHfDREWcInjHJfVJamTXxcR+NC1Lvlj/uB+F7ElJxJ3AwotDm9EOP/W
|bQxc3WqEd9MrGa0zkpfcny5pE9WAE4sHS5O6DdyIuxxwBfAQMmXBGQ44h8QFAAUR
|tCZHZW9yZ2UgS29zdGFzIEdyb3VzIChnZW9yZ2VnQHJtaWkuY29tKQ==
|=LztD
| -----END PGP PUBLIC KEY BLOCK-----
|




Become an MFC-L member | Вернуться в корень Архива |