FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Adding jpeg to a database and browsing them
Posts: 117
Joined: Thu Mar 02, 2006 11:06 AM
Adding jpeg to a database and browsing them
Posted: Sat Sep 01, 2007 09: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

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Adding jpeg to a database and browsing them
Posted: Sat Sep 01, 2007 03: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.

Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Adding jpeg to a database and browsing them
Posted: Sat Sep 01, 2007 03: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
Posts: 117
Joined: Thu Mar 02, 2006 11:06 AM
Adding jpeg to a database and browsing them
Posted: Tue Sep 04, 2007 01: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.

Posts: 117
Joined: Thu Mar 02, 2006 11:06 AM
Adding jpeg to a database and browsing them
Posted: 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

Posts: 189
Joined: Mon Nov 07, 2005 07:36 PM
Adding jpeg to a database and browsing them
Posted: Wed Sep 05, 2007 03:07 PM
Load the image to memvar ...

             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

   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.

Continue the discussion