Store Bitmap in Database File?

Post Reply
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Store Bitmap in Database File?

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dale,

You may store it into a memo field.
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dale,

Replace Memo Field With MemoRead( "bitmap.bmp" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post by dpaterso »

Thanks,

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

Thanks,

Dale.
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post 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.
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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()
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post 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.
Post Reply