Adding jpeg to a database and browsing them

Adding jpeg to a database and browsing them

Postby Willy » Sat Sep 01, 2007 9:46 am

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
Willy
 
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Postby reinaldocrespo » Sat Sep 01, 2007 3:27 pm

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.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby yury » Sat Sep 01, 2007 3:50 pm

hi Willy,

see this sample in FiveWin.com.br


http://www.fivewin.com.br/exibedicas.asp?id=801


regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby Willy » Tue Sep 04, 2007 1:51 pm

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.
Willy
 
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Postby Willy » Wed Sep 05, 2007 11:54 am

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
Willy
 
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Postby dbzap » Wed Sep 05, 2007 3:07 pm

Load the image to memvar ...

Code: Select all  Expand view  RUN
             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


The read data

Code: Select all  Expand view  RUN

   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.
User avatar
dbzap
 
Posts: 189
Joined: Mon Nov 07, 2005 7:36 pm
Location: Chile


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 34 guests