FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Need help with xImage
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Need help with xImage
Posted: Fri Nov 08, 2019 08:14 PM
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 (fw): Select all Collapse
   
     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
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Need help with xImage
Posted: Sat Nov 09, 2019 09:20 AM
Replace the code
Code (fw): Select all Collapse
   If oDbFot:RecCount()=1
      oImg:LoadFromMemory(oDbFot:IMAGEN)
   Else
      oImg:LoadBmp("NULA.JPG")
   Endif

   oImg:Refresh()


with
Code (fw): Select all Collapse
oImg:SetSource( If( oDbFot:RecCounr() == 1, oDbFot:IMAGEN, "NULA.JPG" ) )
Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Need help with xImage
Posted: Sat Nov 09, 2019 11:06 PM

Thanks a lot

Easy... faster in big jpg.

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Need help with xImage
Posted: Sun Nov 10, 2019 08:18 AM
You can even define ximage
Code (fw): Select all Collapse
@ 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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Need help with xImage
Posted: Sun Nov 10, 2019 08:21 AM
Here is a simple way to link XImage displaying blob images to the xbrowse with the least code.
Code (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Need help with xImage
Posted: Sun Nov 10, 2019 08:33 AM
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 (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Need help with xImage
Posted: Sun Nov 10, 2019 01:46 PM

EXCELLENT !!!

Thanks

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650

Continue the discussion