FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Store Bitmap in Database File?
Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 09:00 AM

Is there any way of storing a bitmap in a database file?

This may not sound logical but how else could I do this:

One section of my app contains a database of employees and I would like to be able to store (or attach) their picture to their details.

Displaying the bitmap is no problem - that works perfectly - but I have to assume that the filename is something specific in order to display it e.g. I could have a bitmap file called 'DBP001.BMP' for example in order for me to display the correct picture for employee number 'DBP001'.

If it (the bitmap) could be stored in a database then the filename would not matter as it would just be another field in the database attached to the correct employee record and then simply displayed.

Regards,

Dale.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 09:34 AM

Dale,

You may store it into a memo field.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 09:52 AM

Hello,

Sounds great - but how?

Would you read the existing file off disk (using which function?) and then 'Replace Memo Field' with the data from the read or what?

I mean to say that there is no function that I am aware of to say for example:

gData := BitMap.Ext
Replace Memo Field With gData

Regards,

Dale.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 09:54 AM

Dale,

Replace Memo Field With MemoRead( "bitmap.bmp" )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 09:58 AM

Thanks,

I was going to try to use FOpen() and FRead() etc. etc. but your way sure looks simple enough.

Thanks,

Dale.

Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 10:04 AM

Hold the phone!

It is not quite that simple.

How do you then display the thing?

I mean to say there is no 'Var' associated with TImage.

You can't say:

ReDefine Image oImg Var iMemoFieldImage ...

Dale.

Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 10:17 AM

Although - funny enough - the following does compile with no errors:

...
Local oMemoData

...
oMemoData := MemoRead( 'Test.bmp' )

...
ReDefine Bitmap oBmp Var oMemoData ID 123 ...

Regards,

Dale

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 11:27 AM

Dale,

You may use a temporary file to write the bitmap and then assign it to the bitmap object:

local cTempFile := cTempFile( "\", "bmp" )

MemoWrit( cTempFile, field->image )

oImage:LoadImage( , cTempFile )
oImage:Refresh()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 142
Joined: Tue Jan 24, 2006 09:45 AM
Store Bitmap in Database File?
Posted: Fri Mar 24, 2006 11:49 AM

That is why you created FiveWin and I just use it!!!

Too clever!!!

Thanks - it works perfectly for .bmp and .jpg!!!

Regards,

Dale.

Continue the discussion