Store Bitmap in Database File?

Store Bitmap in Database File?

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

Postby Antonio Linares » Fri Mar 24, 2006 9:34 am

Dale,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Fri Mar 24, 2006 9:54 am

Dale,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby dpaterso » Fri Mar 24, 2006 9:58 am

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

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

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

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

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests