Need help with xImage

Need help with xImage

Postby Adolfo » Fri Nov 08, 2019 8: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: Select all  Expand view  RUN
 
     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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Need help with xImage

Postby nageswaragunupudi » Sat Nov 09, 2019 9:20 am

Replace the code
Code: Select all  Expand view  RUN

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

   oImg:Refresh()
 


with
Code: Select all  Expand view  RUN

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Need help with xImage

Postby Adolfo » 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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Need help with xImage

Postby nageswaragunupudi » Sun Nov 10, 2019 8:18 am

You can even define ximage
Code: Select all  Expand view  RUN

@ 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
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Need help with xImage

Postby nageswaragunupudi » Sun Nov 10, 2019 8:21 am

Here is a simple way to link XImage displaying blob images to the xbrowse with the least code.
Code: Select all  Expand view  RUN
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Need help with xImage

Postby nageswaragunupudi » Sun Nov 10, 2019 8: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: Select all  Expand view  RUN
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Need help with xImage

Postby Adolfo » Sun Nov 10, 2019 1: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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 85 guests