Hello,
I use a MySQL engine to store data.
I want to add a collumn with a JPEG-picture. I know that MySQL can store bitmaps (in a blob I think)
But how can I store a JPG or another graphical file into the databank. How can I read it back to show it into a xBrowse
Greetings and thanks,
Willy
Adding jpeg to a database and browsing them
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Willy;
Hi.
Set a new table with at least two fields. The first field is the key that ids the record back to the master table and the 2nd field is a BLOB field. Then using BLOBIMPORT you can store the jgp (after scanning the image) into the binary field. Using BLOBEXPORT you can recreate the jgp file and display. Works quite well.
You could also add a BLOB field to the table in question and do it directly to that field.
Reinaldo.
Hi.
Set a new table with at least two fields. The first field is the key that ids the record back to the master table and the 2nd field is a BLOB field. Then using BLOBIMPORT you can store the jgp (after scanning the image) into the binary field. Using BLOBEXPORT you can recreate the jgp file and display. Works quite well.
You could also add a BLOB field to the table in question and do it directly to that field.
Reinaldo.
I have done already some tests.
I do further testing. It seems it will work but I have still some questions.
Is'nt it so that with the mentioned functions there is made a temporary file on the harddisk before paintig it in a screen.
Is'nt there a solution that paint the bitmap without writing to hardisk.
Thanks,
Greetings.
Willy.
I do further testing. It seems it will work but I have still some questions.
Is'nt it so that with the mentioned functions there is made a temporary file on the harddisk before paintig it in a screen.
Is'nt there a solution that paint the bitmap without writing to hardisk.
Thanks,
Greetings.
Willy.
The BlobExport() function gives an unresolved external.
Is this function added in the commercial SQL driver from xHarbour.
I also tried to download the Locadora example from the Brazilian Site. To make this test complete I need also the structure of the database.
Is'nt this only a working executable. Is'nt there also a code example.
Thanks
Willy
Is this function added in the commercial SQL driver from xHarbour.
I also tried to download the Locadora example from the Brazilian Site. To make this test complete I need also the structure of the database.
Is'nt this only a working executable. Is'nt there also a code example.
Thanks
Willy
Load the image to memvar ...
The read data
-------------- SPANISH ON -------------------
Lo que hice fue, leer el archivo en forma binaria, transformarlo a Base64 ( texto ), guardarlo, y para recuperarlo lo leo de la base de datos, y lo vuelvo a su forma original, lo pongo en un archivo y lo guardo ( fwrite ), luego lo visualizo. Eso....
Saludos
Code: Select all
cImagen := ""
nBytes := 0
nHandle := FOpen( AllTrim( (PasoLink)->DocuExte ) )
While .T.
nBytes := FRead( nHandle, @cBuffer, nBufSize )
If nBytes > 0
cImagen += SubStr( cBuffer, 1, nBytes )
Else
EXIT
EndIf
EndDo
FClose( nHandle )
If !Empty( cImagen )
cBase64 := cMimeEnc( cImagen ) // transforma en texto
UPDATE EMAELINK SET TEXTO=cBase64
BREAK
EndIf
Code: Select all
cDocuExte := AllTrim( Vcc(TMaes,"DOCUEXTE") )
cBase64 := cMimeDec( Vcc(TMaes,"TEXTO") ) // se des-transforma desde texto !!
If ( nPos := RAT( "\", cDocuExte) )<>0
cFile := StrTran( cDocuExte, SubStr( cDocuExte, 1, nPos ), "" )
Else
cFile := cDocuExte
EndIf
If "PDF" $ UPPER(cFile)
lEsPDF := .T.
Else
lEsPDF := .F.
EndIf
cFile := DEFATMP + "\" + cFile
nHandle := FCreate( cFile )
FWrite( nHandle, cBase64 )
FClose( nHandle )
If lEsPDF // no se por que solo se llama con 2 llamadas
Shellexecute( oPadre:hwnd, "open", cFile )
Shellexecute( oPadre:hwnd, "open", cFile )
Else
Shellexecute( oPadre:hwnd, "open", cFile )
EndIf
-------------- SPANISH ON -------------------
Lo que hice fue, leer el archivo en forma binaria, transformarlo a Base64 ( texto ), guardarlo, y para recuperarlo lo leo de la base de datos, y lo vuelvo a su forma original, lo pongo en un archivo y lo guardo ( fwrite ), luego lo visualizo. Eso....
Saludos
Julio Gonzalez V.
RANDOM S.A.
SISTEMICA S.A.
RANDOM S.A.
SISTEMICA S.A.