XBrowse: how to load image data instead of image name
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
XBrowse: how to load image data instead of image name
I know that we can use bStrImage to display images on an XBrowse column. But it requires a file to work (if I understood correctly). Is there a way to load image data read from a database and display it in the browse without creating a file?
Sorry if that question has already been answered but I searched it without result.
EMG
Sorry if that question has already been answered but I searched it without result.
EMG
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: XBrowse: how to load image data instead of image name
Enrico
I believe any picture that is stored into a database is in a binary form .. and you will probably need to convert the binary back to its original state ( .jpg or .bmp ) before xBrowse can render it.. I am sure Rao can come up with a solution ..
Rick Lipkin
I believe any picture that is stored into a database is in a binary form .. and you will probably need to convert the binary back to its original state ( .jpg or .bmp ) before xBrowse can render it.. I am sure Rao can come up with a solution ..
Rick Lipkin
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: XBrowse: how to load image data instead of image name
You do not need to do anything at all.
If the column data is binary data and also image data, it displays the data as image by itself.
Test:
Field "IMAGE" is a memo field containing image data. XBrowse detects that the data is image data and displays it as image.
Field "DETAILS" also is a memo field but containing text data. XBrowse knows that this data is to be displayed as multi-line text.
So, whether the data source is DBF, ADO or any other, if the column value is image-data, xbrowse detects it and displays it as image. We do not need to do anything and please do not add any unnecessary program code.
Another situation:
Sometimes, we may store image file name in a field. Or it can be a file name containing text, image.
By default, XBrowse displays the contents of the field, i.e., the file name as text.
By setting the datatype of the column to "F" ( oCol:cDataType := "F" ), we tell the xbrowse to treat the data as file name, read the contents of the file and display the contents of the file appropriately.
Test:
If the column data is binary data and also image data, it displays the data as image by itself.
Test:
Code: Select all
#include "fivewin.ch"
REQUEST DBFCDX
function Main()
local oDlg, oBrw
USE "C:\FWH\SAMPLES\WWONDERS" NEW VIA "DBFCDX"
DEFINE DIALOG oDlg SIZE 800,600 PIXEL TRUEPIXEL
@ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "WWONDERS" ;
COLUMNS "NAME", "IMAGE", "DETAILS" ; // Can use AUTOCOLS too
LINES NOBORDER
WITH OBJECT oBrw
:nRowHeight := 100 // pixels
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
return nil
Field "DETAILS" also is a memo field but containing text data. XBrowse knows that this data is to be displayed as multi-line text.
So, whether the data source is DBF, ADO or any other, if the column value is image-data, xbrowse detects it and displays it as image. We do not need to do anything and please do not add any unnecessary program code.
Another situation:
Sometimes, we may store image file name in a field. Or it can be a file name containing text, image.
By default, XBrowse displays the contents of the field, i.e., the file name as text.
By setting the datatype of the column to "F" ( oCol:cDataType := "F" ), we tell the xbrowse to treat the data as file name, read the contents of the file and display the contents of the file appropriately.
Test:
Code: Select all
#include "fivewin.ch"
function Main()
local oDlg, oBrw
local aData := { { "OLGA1", "c:\fwh\bitmaps\olga1.jpg" }, ;
{ "SEA", "c:\fwh\bitmaps\sea.bmp" } }
DEFINE DIALOG oDlg SIZE 360,500 PIXEL TRUEPIXEL
@ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE aData ;
COLUMNS 1, 2 ; // Can use AUTOCOLS too
HEADERS "NAME", "IMAGE" ;
LINES NOBORDER
WITH OBJECT oBrw
:aCols[ 2 ]:cDataType := "F"
:nRowHeight := 200 // pixels
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: XBrowse: how to load image data instead of image name
Thank you Rao, but I can't use the command syntax. How can I assign the binary data to the column?
oBrw:bStrImage = ???
or what?
EMG
oBrw:bStrImage = ???
or what?
EMG
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: XBrowse: how to load image data instead of image name
You mean you do not want to use command syntax to create XBrowse?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: XBrowse: how to load image data instead of image name
This is enough
Code: Select all
oCol:bEditValue := { || ( cAlias )->IMAGE }
// or
oCol:bEditValue := { || oRs:Fields( "image" ):Value }
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: XBrowse: how to load image data instead of image name
I tried:
but it doesn't work (it displays nothing).
What am I doing wrong?
EMG
Code: Select all
oCol:bEditValue := { || MemoRead( cImg ) }
What am I doing wrong?
EMG
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: XBrowse: how to load image data instead of image name
Code: Select all
#include "fivewin.ch"
function Main()
local aImages := { "c:\fwh\bitmaps\olga1.jpg", "c:\fwh\bitmaps\sea.bmp" }
local oDlg, oBrw
DEFINE DIALOG oDlg SIZE 750,600 PIXEL TRUEPIXEL
@ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE aImages NOBORDER
WITH OBJECT oBrw:AddCol()
:cHeader := "NAME"
:bEditValue := { || aImages[ oBrw:nArrayAt ] }
:nWidth := 300
END
WITH OBJECT oBrw:AddCol()
:cHeader := "IMAGE"
:bEditValue := { || MemoRead( aImages[ oBrw:nArrayAt ] ) }
:nWidth := 300
END
WITH OBJECT oBrw
:nRowHeight := 200
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: XBrowse: how to load image data instead of image name
Thank you! It was a problem related to a local index variable. I solved with the usual "detached local" technique.
EMG
EMG
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: XBrowse: how to load image data instead of image name
I discovered that I can use bStrImage for both image name file and image binary data!
EMG
EMG
- mauri.menabue
- Posts: 89
- Joined: Thu Apr 17, 2008 2:38 pm
Re: XBrowse: how to load image data instead of image name
Hi Enrico
I have two questions to ask :
1 what is the "detached local" technique.
Can you post an example?
2 how store an image into a memo file.
TIA
I have two questions to ask :
1 what is the "detached local" technique.
Can you post an example?
2 how store an image into a memo file.
TIA
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: XBrowse: how to load image data instead of image name
This is without detached local (you get an error):mauri.menabue wrote:Hi Enrico
I have two questions to ask :
1 what is the "detached local" technique.
Can you post an example?
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL aVar := { SPACE( 20 ), SPACE( 20 ) }
LOCAL i
DEFINE DIALOG oDlg
FOR i = 1 TO 2
@ i, 1 GET aVar[ i ]
NEXT
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL aVar := { SPACE( 20 ), SPACE( 20 ) }
LOCAL i
DEFINE DIALOG oDlg
FOR i = 1 TO 2
// @ i, 1 GET aVar[ i ]
MKGET( aVar, i )
NEXT
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
STATIC FUNCTION MKGET( aVar, i )
@ i, 1 GET aVar[ i ]
RETURN NIL
REPLACE FIELD -> memofld WITH MEMOREAD( cImgFile )mauri.menabue wrote:2 how store an image into a memo file.
EMG
- Marc Venken
- Posts: 727
- Joined: Tue Jun 14, 2016 7:51 am
Re: XBrowse: how to load image data instead of image name
// detached local
Strange that we need a extra function to get it working ....
Is there a surplus that we do it like this ?
Strange that we need a extra function to get it working ....
Is there a surplus that we do it like this ?
Last edited by Marc Venken on Tue Nov 03, 2020 9:21 am, edited 1 time in total.
Marc Venken
Using: FWH 20.08 with Harbour
Using: FWH 20.08 with Harbour