Page 1 of 1

Problems Using Bitmap in Postgress

Posted: Wed Aug 10, 2016 8:53 am
by digitsoft
Hi Al Group
Alguin know how to save a JPG in a Table in Postgress

I am using this but it does not work when I want to present
cfoto: = __b64enc (MEMOREAD (cFotoFile)) //ot4xb.dll Paul

I think if the file again with the image looks good in the file
MEMOWRIT ( "C: \ LOGS \ Foto.jpg" __b64dec (cfoto))

but if what I want is to paint the picture with DC_BitMapDraw (oMarcoFoto, __b64dec (cfoto))

no nothing.

Re: Problems Using Bitmap in Postgress

Posted: Wed Aug 10, 2016 10:18 am
by Auge_Ohr
hi,

did you talk about Xbase++ PgDBE or native Access using libpq.dll ?

also remember PDR 6009 : 14 Byte from Bitmap Header are missing when using o:SetBuffer()

Re: Problems Using Bitmap in Postgress

Posted: Wed Aug 10, 2016 11:18 am
by digitsoft
I am using SQL Express Demo and xBase 1.9.355, and I want to know how to add a photo on a table and then show postgress

Re: Problems Using Bitmap in Postgress

Posted: Thu Aug 11, 2016 6:39 pm
by Auge_Ohr
PostgreSQL Table have Type "BLOB" and "bytea" to store binary Data.

i think Sqlexpress use Postgres ODBC ... ask Boris what Format can be used by ODBC

i use "bytea" with XbpBitmap() and cBin2Hex() / cHex2Bin() from ot4xb

"store" to PG

Code: Select all

      oBMP := XBPBITMAP() :new() :create()
      oBMP:loadFile( cFile )
      cBuffer := oBMP:setbuffer()

      // cBuffer missing 14 byte Header need workaround
      //
      cSql   += ::_aBroFields[ nCol ] [ DBS_NAME ] + "= '\x" + cBin2Hex( cBuffer ) + "' "
      cAlias := ::_aBroFields[ nCol ] [ DBS_ALIAS ] + "."
      cWhere := cAlias + "__record" + "=" + STR( nRecord )
      cSql   += " WHERE " + cWhere
"load" from PG

Code: Select all

      cFeld := ::oResult:getValue( nRow - 1, nCol - 1 )

      // strip "\x" 
      //
      IF SUBSTR( cFeld, 1, 2 ) = "\x"
         cFeld := SUBSTR( cFeld, 3, LEN( cFeld ) - 2 )
      ENDIF
 
      oPS := XBPPRESSPACE() :new() :create( oDlg:drawingArea:winDevice() )
      oBMP := XBPBITMAP() :new() :create( oPS )

      // Hex to Bin Format using ot4xb
      //
      oBMP:setBuffer( cHex2Bin( cFeld ) )

Re: Problems Using Bitmap in Postgress

Posted: Fri Aug 12, 2016 5:26 am
by digitsoft
Hi Jimmy
Where you can get this 2 functions
cBin2Hex()
cHex2Bin()

Remember that I am using xBase 1.9.355

Re: Problems Using Bitmap in Postgress

Posted: Fri Aug 12, 2016 5:30 am
by Leon Berger
digitsoft wrote:Where you can get this 2 functions
cBin2Hex()
cHex2Bin()
You can get it here (free):
http://ot4xb.xbwin.com

Re: Problems Using Bitmap in Postgress

Posted: Fri Aug 12, 2016 5:35 am
by Tom
You may also use StrToHex/HexToStr from the Xbase Tools, free in Xbase++ 2.0 or higher. ;) They work for binaries aswell.

Re: Problems Using Bitmap in Postgress

Posted: Fri Aug 12, 2016 7:40 am
by rdonnay
You can also use DC_Var2HexString() and DC_HexString2Var().