path of an image

User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

path of an image

Post by MdaSolution »

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
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: path of an image

Post by Rick Lipkin »

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
User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: path of an image

Post by MdaSolution »

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
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: path of an image

Post by ukoenig »

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

Image

Best regards
Uwe :lol:
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
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: path of an image

Post by nageswaragunupudi »

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
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Post by hua »

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

TIA.
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: path of an image

Post by nageswaragunupudi »

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
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Post by hua »

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: path of an image

Post by nageswaragunupudi »

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
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Post by hua »

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: path of an image

Post by nageswaragunupudi »

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
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Post by hua »

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

TIA
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: path of an image

Post by MdaSolution »

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

Re: path of an image

Post by nageswaragunupudi »

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

TIA
Please see
http://forums.fivetechsupport.com/viewt ... 43#p118743
Regards

G. N. Rao.
Hyderabad, India
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: path of an image

Post by Bayron »

MdaSolution,

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

Code: Select all

LOCAL ExePath  := cFilePath( GetModuleFileName( GetInstance() ) )
LOCAL BmpPath := ExePath + "\bitmaps\pos"
 
=====>

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

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

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