Page 1 of 1

Need help with xImage

PostPosted: Fri Nov 08, 2019 8:14 pm
by Adolfo
Hi Fivewinners

Which are the equivalents of Image:LoadFromMemory and Image:LoadBmp()
I Used them with FreeImage.dll, now I want to test xImage to replace these lines


Code: Select all  Expand view
 
     oDbFot:=oSvr:Rowset("select IMAGEN from photos where CODIGO='" + CODIGO + "'")

   If oDbFot:RecCount()=1
      oImg:LoadFromMemory(oDbFot:IMAGEN)
   Else
      oImg:LoadBmp("NULA.JPG")
   Endif

   oImg:Refresh()


Thanks in advance

Re: Need help with xImage

PostPosted: Sat Nov 09, 2019 9:20 am
by nageswaragunupudi
Replace the code
Code: Select all  Expand view

   If oDbFot:RecCount()=1
      oImg:LoadFromMemory(oDbFot:IMAGEN)
   Else
      oImg:LoadBmp("NULA.JPG")
   Endif

   oImg:Refresh()
 


with
Code: Select all  Expand view

oImg:SetSource( If( oDbFot:RecCounr() == 1, oDbFot:IMAGEN, "NULA.JPG" ) )
 

Re: Need help with xImage

PostPosted: Sat Nov 09, 2019 11:06 pm
by Adolfo
Thanks a lot

Easy... faster in big jpg.

Re: Need help with xImage

PostPosted: Sun Nov 10, 2019 8:18 am
by nageswaragunupudi
You can even define ximage
Code: Select all  Expand view

@ r,c XIMAGE oImg SOURCE oDbFot:imagen SIZE w,h OF oDlg
 

You need not worry if the oDbFot is empty or not. In case oDbFot is empty, ximage will display a blank image on its own.

Re: Need help with xImage

PostPosted: Sun Nov 10, 2019 8:21 am
by nageswaragunupudi
Here is a simple way to link XImage displaying blob images to the xbrowse with the least code.
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn, oRs, oBrw, oDlg, oFont, oImage

   oCn   := FW_DemoDB()
   oRs   := oCn:RowSet( "wwonders" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 900,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE 400,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "NAME", "DETAILS" ;
      COLSIZES 150 ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nHeadStrAligns   := AL_CENTER
      :nStretchCol   := 2
      :nRowHeight    := 80
      //
      :bChange    := { || oDlg:Update() }
      //
      :CreateFromCode()
   END

   @ 20,420 XIMAGE oImage SOURCE oRs:image OF oDlg SIZE -20,-20 UPDATE

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()
   oCn:Close()

return nil
 


Image

Re: Need help with xImage

PostPosted: Sun Nov 10, 2019 8:33 am
by nageswaragunupudi
This is another simple way to achieve the same effect, without creating any additional control like XImage, Image or Bitmap. This sample uses xbrowse's built-in capabilities to display images.

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn, oRs, oBrw, oDlg, oFont

   oCn   := FW_DemoDB()
   oRs   := oCn:RowSet( "wwonders" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 900,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "NAME", "DETAILS", "IMAGE" ;
      COLSIZES 150,250 ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nHeadStrAligns   := AL_CENTER
      :nStretchCol   := 3
      :nRowHeight    := 80

      :oRightCol     := :image
      WITH OBJECT :oRightCol
         :lFullHeight   := .t.
         :nDataBmpAlign  := AL_CENTER
      END
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()
   oCn:Close()

return nil
 


Image

Re: Need help with xImage

PostPosted: Sun Nov 10, 2019 1:46 pm
by Adolfo
EXCELLENT !!!

Thanks