Page 1 of 1

Store Bitmap in Database File?

PostPosted: Fri Mar 24, 2006 9:00 am
by dpaterso
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.

PostPosted: Fri Mar 24, 2006 9:34 am
by Antonio Linares
Dale,

You may store it into a memo field.

PostPosted: Fri Mar 24, 2006 9:52 am
by dpaterso
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.

PostPosted: Fri Mar 24, 2006 9:54 am
by Antonio Linares
Dale,

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

PostPosted: Fri Mar 24, 2006 9:58 am
by dpaterso
Thanks,

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

Thanks,

Dale.

PostPosted: Fri Mar 24, 2006 10:04 am
by dpaterso
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.

PostPosted: Fri Mar 24, 2006 10:17 am
by dpaterso
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

PostPosted: Fri Mar 24, 2006 11:27 am
by Antonio Linares
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()

PostPosted: Fri Mar 24, 2006 11:49 am
by dpaterso
That is why you created FiveWin and I just use it!!!

Too clever!!!

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

Regards,

Dale.