FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour path of an image
Posts: 401
Joined: Tue Jan 05, 2010 02:33 PM
path of an image
Posted: Wed Jul 27, 2011 07:07 PM

I want save a path of a image into a get of a dialog
I can explain
I use to take the image Cgetfile but it give me

c:\bar\bitmaps\risto\cafe\cafe.jpg

on c\bar there is the Exe file

I want save only .\bitmaps\risto\cafe\cafe.jpg

or

If I have in future another folder down the cafe folder

all path respect the exe name path (GetModuleFileName(GetInstance()))

any solution pls ?

FWH .. BC582.. xharbour
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: path of an image
Posted: Wed Jul 27, 2011 07:48 PM

Just curious .. why don't you import your images into a .rc file and call them from a compiled resource rather than from a file location?.. Reason I ask is if you store your images in a sub folder the end user may accidentally delete them and then you lose all reference to them and your images fail to load.

Check the batch file rc2dll32.bat to be able to compile all your .rc files into a .res and then include the .res into your final compile to create the .exe.

Rick Lipkin

Posts: 401
Joined: Tue Jan 05, 2010 02:33 PM
Re: path of an image
Posted: Wed Jul 27, 2011 09:53 PM

Rick it is catalog user I cannot insert thenm on a rc resources

if you create a archive of friends and insert a friend and you want insert his photo , why you must insert the photo into a rc file ?

FWH .. BC582.. xharbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: path of an image
Posted: Wed Jul 27, 2011 10:42 PM
You can use a Substring like :
( I noticed ".\" returns a wrong Backslash-direction. Using : "." + "\" works fine.

1. Get Your Main-directory :
c_path := CURDRIVE() + ":\" + GETCURDIR()

2. the complete Path ( can be the Result from Image-selection ) :
cFile := c_path + "\Bitmaps\Olga.jpg"
Msgalert ( c_path + "\Bitmaps\Olga.jpg" )


3. create the String :
cNewfile := "." + "\" + Substr(cFile, Len(c_path) + 2 , Len(cFile) )
Msgalert( cNewFile )


4. Test if File exists :
IF FILE ( cNewfile )
Msgalert( cNewfile + " found !", "Attention" )
ENDIF


Tested and works !!!
1. the full path
2. only the Subdirectory(s) with File
3. the Seek-result



Best regards
Uwe :-)
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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: path of an image
Posted: Thu Jul 28, 2011 01:35 AM
MdaSolution wrote:Rick it is catalog user I cannot insert thenm on a rc resources


if you create a archive of friends and insert a friend and you want insert his photo , why you must insert the photo into a rc file ?

I would prefer to store the image buffer in a memo field if I use RDD or into a binary field if I am using some RDMS.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: path of an image
Posted: Thu Jul 28, 2011 02:04 AM

Rao,
Do you have any examples on how to use memo fields to deal with images?

TIA.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: path of an image
Posted: Thu Jul 28, 2011 02:41 AM
hua wrote:Rao,
Do you have any examples on how to use memo fields to deal with images?

TIA.

DBFCDX RDD.
If we are having a memo filed by name IMAGE in a dbf file.

FIELD->IMAGE := MemoRead( "myimage.jpg" ) stores the image buffer in the memo field.
MemoWrit( cImageFileName, FIELD->IMAGE ) saves the image buffer to a file on disk.

fwh\samples\wwonders.dbf has a memofield IMAGE holding image buffers of different jpegs.

You can view these images with the simple program \fwh\samples\xbrimag1.prg.
This is a better way to store images of employees, products, etc.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: path of an image
Posted: Thu Jul 28, 2011 04:35 AM

Thank you very much Rao. This will solve the problem where user remembers to make regular backups of their data but not of the images.

Does it only work with DBFCDX and not DBFNTX?

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: path of an image
Posted: Thu Jul 28, 2011 05:19 AM
hua wrote:Thank you very much Rao. This will solve the problem where user remembers to make regular backups of their data but not of the images.

Does it only work with DBFCDX and not DBFNTX?

DBFCDX or ADSCDX, ADSADT as far as I know. I think DBFNTX memo fields can not have binary data, I am not sure.

Please note that FPT files will be very large because it contains all image data. May require periodical packing. Still this is a lot better than dealing with number of different files.

Works with all RDMS with ADO.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: path of an image
Posted: Thu Jul 28, 2011 08:41 AM

One last question on the subject Rao, what's the fastest way to display the image in the memo field? Is there any faster method compared to:
i. read memo field
ii. write binary data in memo field to a temporary file
iii. get control to read that file and refresh it.

Off the top of my head, the optimized way would seem to be to read the binary data directly into memory and get whatever control meant to display the image to use that. I'm just not sure whether that's possible to do

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: path of an image
Posted: Thu Jul 28, 2011 09:43 AM
Off the top of my head, the optimized way would seem to be to read the binary data directly into memory and get whatever control meant to display the image to use that. I'm just not sure whether that's possible to do

You are absolutely right. It is not efficient to write to disk and then read it again.
If you run the sample xbrimag1.prg, you will notice that the image buffer is directly displayed in the browse. There are no disk writes and reads.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: path of an image
Posted: Thu Jul 28, 2011 01:06 PM

Any snippet of how to do it with, let say, TImage control?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 401
Joined: Tue Jan 05, 2010 02:33 PM
Re: path of an image
Posted: Sat Jul 30, 2011 08:56 AM
Sorry,

Perhaps I not understood How resolve it

I have the exe file C:\risto\Risto.exe

I have images for an cash application into .\bitmaps\pos

and on this folder we have many other folders

sample :

.\bitmaps\pos\imagenes

and on this we have for a sample :

.\bitmaps\pos\imagenes\bocadillos
.\bitmaps\pos\imagenes\cafes
.\bitmaps\pos\imagenes\cervezas

and on each folders we have the images sample

.\bitmaps\pos\imagenes\cervezas\heineken1.jpg


I wish save the string ".\bitmaps\pos\imagenes\cervezas\heineken1.jpg"

But I don't Know where the final user post his images

I wish save all folders ( and subfolders) respct the EXE FOlder that in this case in on C:\risto\Risto.exe
FWH .. BC582.. xharbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: path of an image
Posted: Fri Sep 02, 2011 03:16 PM
hua wrote:Any snippet of how to do it with, let say, TImage control?

TIA

Please see
viewtopic.php?f=6&t=22302&p=118743#p118743
Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: path of an image
Posted: Fri Sep 02, 2011 04:34 PM
MdaSolution,

I think that you are trying to figure out where your .Exe file is running from..... You can use this:

Code (fw): Select all Collapse
LOCAL ExePath  := cFilePath( GetModuleFileName( GetInstance() ) )
LOCAL BmpPath := ExePath + "\bitmaps\pos"

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...