Jpg not shown in Xbrowse

Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 12:19 am

Hello,

I tried some samples, but could not get Xbrowse to show a picture in de browse.

I read the jpg's from a dir. and put the names into a dbf in the second field in order to show it. No result.

Do I need to give also a full path before the filename ? Could test it just now.

I read that :

oStru:aCols[ 2 ]:cDatatype := "F"

should do the trick ?

Piece of code

Code: Select all  Expand view


   REDEFINE XBROWSE oStru ID 320 OF oDlg ;
      DATASOURCE "foto" ;
      COLUMNS "foto","Pic" ;
      COLSIZES 500,150 ;
      CELL LINES NOBORDER FASTEDIT

   oStru:bRClicked := { || XbrShowSizes( oStru )  }
   oStru:nRowHeight                 := 66

   //oStru:aCols[ 2 ]:nEditType       := TYPE_IMAGE
   oStru:aCols[ 2 ]:cDatatype := "F"
   //oStru:aCols[ 2 ]:lBmpStretch     := .t.
   //oStru:aCols[ 2 ]:lBmpTransparent := .t.
   //oStru:aCols[ 2 ]:bStrImage       := {|oCol, oStru| oStru:aRow[ 1 ] }
   //oStru:aCols[ 2 ]:nDataBmpAlign   := AL_CENTER


 


Regards,
Marc
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 9:56 am

Do I need to give also a full path before the filename ? Could test it just now.

Full path or relative path, but full path is always safe.

aCols[ 2 ]:cDataType := 'F' // is correct

Remove all other code.
With XBrowse less the code you write the better it is.
Regards

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

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 10:00 am

small example with an array:

aDir := DIRECTORY( "c:\fwh\bitmaps\pngs\*.png" )
AEval( aDir, { |a| a[ 2 ] := "c:\fwh\bitmaps\pngs\" + a[ 1 ] } )

@ 10,10 XBROWSE oBrw SIZE -10,-10 OF oDlg DATASOURCE aDir COLUMNS 1, 2

oBrw:aCols[ 2 ]:cDataType := 'F'
oBrw:nWidths := 70
oBrw:nRowHeight := 70
oBrw:CreateFromCode()

ACTIVATE DIALOG ..........
Regards

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

Re: Jpg not shown in Xbrowse

Postby ukoenig » Wed Nov 16, 2016 1:09 pm

Marc,

I did some adjustments to my imagebrowser ( created one year ago ) and recompiled with the new FWH-release..
There is a image-format-filter, image-seek and a image-export included.
instead using a extra cell for the file-info, there is a yellow-bottom-area defined.

I can extract the needed section to display the images from a directory with xBrowse.
All other adjustments and selections will be excluded. Otherwise maybe it gets to complicated.

Image

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 1:54 pm

Rao,

The sample with the array works, but with the database not !

Maybe it has nothing to do with Xbrowse, but with the way I create and fill the database ?
In the file there is a full path, just like in the array i believe.

I prefer the database way because i know how to work with xbrowse and wildseek, scope,... what i need in the process.

Working with array


aDir := DIRECTORY( "c:\fwtesting\picture\*.jpg" )
AEval( aDir, { |a| a[ 2 ] := "c:\fwtesting\picture\" + a[ 1 ] } )

REDEFINE XBROWSE oStru ID 320 OF oDlg ;
DATASOURCE aDir ;
COLUMNS 1,2 ;
COLSIZES 500,150 ;
CELL LINES NOBORDER FASTEDIT

oStru:aCols[ 2 ]:cDataType := 'F'
oStru:nWidths := 170
oStru:nRowHeight := 170


Not working with DBF


ADIR("*.jpg", aDbf)

aStruct := {}
AADD(aStruct, { "foto", "C", 150, 0 })
AADD(aStruct, { "pic", "C", 150, 0 })

DbCreate( "fotofile.dbf", aStruct)
use fotofile NEW ALIAS foto VIA "DBFCDX"

for i = 1 to len(adbf)
foto->(dbappend())
foto->foto = adbf[i]
foto->pic = "c:\fwpic\"+adbf[i]
next


REDEFINE XBROWSE oStru ID 320 OF oDlg ;
DATASOURCE "foto" ;
COLUMNS "foto","Pic" ;
COLSIZES 300,250 ;
CELL LINES NOBORDER FASTEDIT

oStru:aCols[ 2 ]:cDatatype := "F"
oStru:nWidths := 170
oStru:nRowHeight := 170
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 2:01 pm

For xbrowse it does not matter if the datasource is array or dbf or ado or whatever.

Most likely the path you saved in the dbf may not be correct
Please check again
Regards

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

Re: Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 2:32 pm

nageswaragunupudi wrote:For xbrowse it does not matter if the datasource is array or dbf or ado or whatever.

Most likely the path you saved in the dbf may not be correct
Please check again


I checked, and they are the same. If I comment out the

oStru:aCols[ 2 ]:cDatatype := "F"

then I see the same file name in de array version and the dbf version.

I will look further, since I probable will have looked over some issue.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 2:37 pm

Please replace

ADIR("*.jpg", aDbf)

with
aDbf := DIRECTORY( "c:\fwpic\*.jpg" )
Regards

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

Re: Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 2:51 pm

Here is the full code for this function, because i think it's somewhere else that the issue is comming from.

This post came before youre answer. I also believe that the issue is somewhere in the adir (directory) stuff.


Code: Select all  Expand view

static function orderoverzicht()

   local oDlg, oFont, oBrw,cfactart := "dial", nWild := 2, aDbf[ADIR("*.jpg")]
   local cList, aFlds, aHdrs, oBold
   local nChoice, uDataSource, nCombo1:= 1 , nCombo2:= 1

   USE nofoto NEW

   ADIR("*.jpg", aDbf)

   aStruct := {}
   AADD(aStruct, { "foto", "C", 150, 0 }) // Id
   AADD(aStruct, { "pic", "C", 150, 0 }) // Id
   AADD(aStruct, { "path", "C", 150, 0 }) // Id

   DbCreate( "fotofile.dbf", aStruct)
   use fotofile NEW ALIAS foto VIA "DBFCDX"

   DBSELECTAREA( "foto" )

   for i = 1 to len(adbf)
     foto->(dbappend())
     foto->foto = adbf[i]
     foto->pic = alltrim("c:\fwpic\"+adbf[i])
     foto->path = alltrim("
c:\fwpic\"+adbf[i])
   next

   INDEX ON foto->foto TAG foto // DESCENDING
   foto->(dbgotop())

   xbrowse()

   DBSELECTAREA( "
nofoto" )


   cList := "
foto"

   DEFINE FONT oBold NAME 'TAHOMA' SIZE 0,-12 BOLD
   DEFINE FONT oFont NAME "
TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg RESOURCE "
orderdlg";
      TITLE "
Fotolijst zonder foto : "

   aFlds := aHdrs := HB_ATokens( cList, ',' )

   REDEFINE XBROWSE oBrw ID 200 OF oDlg ;
      DATASOURCE "
nofoto" ;
      COLUMNS "
ID","naam","pagina","RefLev","Kleur","Source" ;
      COLSIZES 150,250,100,150,150,450 ;
      AUTOSORT CELL LINES NOBORDER FASTEDIT

   oBrw:bRClicked := { || XbrShowSizes( oBrw )  }


   WITH OBJECT oBrw

      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS

      :bChange := { || SET_SCOPE(oStru), ('foto')->(DBGOTOP()),oStru:Refresh() }

   END

   aDir := DIRECTORY( "
c:\fwpic\*.jpg" )
   AEval( aDir, { |a| a[ 2 ] := "
c:\fwpic\" + a[ 1 ] } )



   REDEFINE XBROWSE oStru ID 320 OF oDlg ;
      DATASOURCE "
foto" ;
      COLUMNS "
foto","Pic","Path" ;
      COLSIZES 200,150,200 ;
      CELL LINES NOBORDER FASTEDIT

   oStru:aCols[ 2 ]:cDatatype := "
F"
   oStru:nWidths := 170
   oStru:nRowHeight := 170

*/
/*
   REDEFINE XBROWSE oStru ID 320 OF oDlg ;
      DATASOURCE aDir ;
      COLUMNS 1,2 ;
      COLSIZES 500,150 ;
      CELL LINES NOBORDER FASTEDIT

   oStru:aCols[ 2 ]:cDataType := 'F'
   oStru:nWidths := 170
   oStru:nRowHeight := 170

 */

   WITH OBJECT oStru

      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 2 )
      :cFilterFld    := "
foto"

      :bClrSel          := { || { CLR_BLACK, CLR_HGRAY }}
      :l2007 := .t.


   END

//   REDEFINE BUTTON ID 101 OF oDlg ACTION (oStru:seek("
"),('foto')->(DBGOTOP()),oStru:SetFocus())
   REDEFINE BUTTON ID 101 OF oDlg ACTION (("
foto")->( ORDSCOPE(1, "" ) ),('foto')->(DBGOTOP()),oStru:SetFocus())
   REDEFINE BUTTON ID 350 OF oDlg ACTION (oStru:seek("
"),SET_SCOPE(oStru),('foto')->(DBGOTOP()),oStru:SetFocus())

   REDEFINE COMBOBOX oStru:cFilterFld ID 100 of oDLG ;
      ITEMS aHdrs ;
      ON CHANGE ( oStru:Seek( "
" ), oStru:SetFocus() )

   REDEFINE COMBOBOX nWild ID 110 of oDLG ;
      ITEMS { "
Start met", "Bevat tekst" } ;
      ON CHANGE ( oStru:lSeekWild := ( nWild == 2 ), ;
                  oStru:Seek( If( oStru:lSeekWild, oStru:cSeek, "
" ) ), ;
                  oStru:SetFocus() )


   //SET_SCOPE(oStru)

   REDEFINE say ostru:oSeek prompt ostru:cSeek ID 650 OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!' UPDATE

   ACTIVATE DIALOG oDlg CENTERED on init ( SET_SCOPE(oStru),oBrw:setfocus(),oStru:refresh(),odlg:update() )

   RELEASE FONT oFont
   close all

return nil

STATIC FUNCTION SET_SCOPE(oStru)
LOCAL cNName := alltrim(nofoto->reflev)

DBSELECTAREA( "
foto" )
("
foto")->( ORDSCOPE(0, cNName ) )
("
foto")->(ORDSCOPE(1, cNName ) )
oStru:Refresh()

RETURN NIL


Last edited by Marc Venken on Wed Nov 16, 2016 3:02 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 3:00 pm

nageswaragunupudi wrote:Please replace

ADIR("*.jpg", aDbf)

with
aDbf := DIRECTORY( "c:\fwpic\*.jpg" )


A quick replace gives issues, (error)

DATA TYPE ERROR

for i = 1 to len(adbf)
foto->(dbappend())
foto->foto = adbf[i]
foto->pic = alltrim("c:\fwpic\"+adbf[i])
foto->path = alltrim("c:\fwpic\"+adbf[i])
next


because the aDbf will be multidimensional i believe when using directory function.

But I will look into the array stuff and try it out.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 3:15 pm

This way we reach no where.

If you please wait a little, I try to give you here a simple and fully working program.
You just need to change the folder name and file extension.

Please wait for my next post

Meanwhile can you please let me know the FWH version you are using?
Regards

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

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 4:17 pm

Mr Marc

Let me quickly add that you are correct. It is working with arrays and not DBF.
This was working in older versions. There is a bug introduced in some recent versions.
I need to find the but, fix and then help you to modify your xbrowse.prg

I shall be glad if you can let me know your fwh version
Regards

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

Re: Jpg not shown in Xbrowse

Postby nageswaragunupudi » Wed Nov 16, 2016 4:26 pm

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

function Main()

   local cFolder     := "c:\fwh\bitmaps\"
   local cImgType    := "
*.JPG"
   local oDlg, oBrw, aDir, n

   aDir     := DIRECTORY( cFolder + cImgType )
   DBCREATE( "
photo", { { "TITLE", 'C', 20, 0 }, { "FILE", 'C', 150, 0 } } )
   USE PHOTO EXCLUSIVE
   for n := 1 to Len( aDir )
      DBAPPEND()
      PHOTO->TITLE   := aDir[ n, 1 ]
      PHOTO->FILE    := cFolder + aDir[ n, 1 ]
   next
   DBGOTOP()

   DEFINE DIALOG oDlg SIZE 600,500 PIXEL TRUEPIXEL TITLE FWVERSION
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg DATASOURCE "
PHOTO" ;
      COLUMNS "
TITLE", "FILE" NOBORDER

   //oBrw:aCols[ 2 ]:cDataType := 'F'
   oBrw:aCols[ 2 ]:bStrImage    :=  { || FIELD->FILE }
   oBrw:nRowHeight   := 100
   oBrw:nWidths      := 100
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

You may substitute your folder name and view your Jpg files.

Actually
oBrw:aCols[ 2 ]:cDataType := 'F'
without
oBrw:aCols[ 2 ]:bStrImage := { || FIELD->FILE }
should also work and it is easy for programming.
We shall fix the bug and inform ASAP.

But your work need not stop. You can go ahead with your implementation with the above code.
Regards

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

Re: Jpg not shown in Xbrowse

Postby Marc Venken » Wed Nov 16, 2016 9:06 pm

FiveWin Version: FWH 15.12

The solution works !
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests