Need help with xImage

Post Reply
User avatar
Adolfo
Posts: 815
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile
Contact:

Need help with xImage

Post 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

   
     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
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Need help with xImage

Post by nageswaragunupudi »

Replace the code

Code: Select all

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

   oImg:Refresh()
 
with

Code: Select all

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

G. N. Rao.
Hyderabad, India
User avatar
Adolfo
Posts: 815
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile
Contact:

Re: Need help with xImage

Post by Adolfo »

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
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Need help with xImage

Post by nageswaragunupudi »

You can even define ximage

Code: Select all

@ 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: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Need help with xImage

Post by nageswaragunupudi »

Here is a simple way to link XImage displaying blob images to the xbrowse with the least code.

Code: Select all

#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: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Need help with xImage

Post 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

#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
Adolfo
Posts: 815
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile
Contact:

Re: Need help with xImage

Post by Adolfo »

EXCELLENT !!!

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

http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
Post Reply