path of an image

path of an image

Postby MdaSolution » Wed Jul 27, 2011 7: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
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: path of an image

Postby Rick Lipkin » Wed Jul 27, 2011 7: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
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: path of an image

Postby MdaSolution » Wed Jul 27, 2011 9: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
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: path of an image

Postby ukoenig » 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

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

Re: path of an image

Postby nageswaragunupudi » Thu Jul 28, 2011 1: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: path of an image

Postby hua » Thu Jul 28, 2011 2: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Postby nageswaragunupudi » Thu Jul 28, 2011 2: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: path of an image

Postby hua » Thu Jul 28, 2011 4: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Postby nageswaragunupudi » Thu Jul 28, 2011 5: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: path of an image

Postby hua » Thu Jul 28, 2011 8: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Postby nageswaragunupudi » Thu Jul 28, 2011 9: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: path of an image

Postby hua » Thu Jul 28, 2011 1: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: path of an image

Postby MdaSolution » Sat Jul 30, 2011 8: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
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: path of an image

Postby nageswaragunupudi » Fri Sep 02, 2011 3: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: path of an image

Postby Bayron » Fri Sep 02, 2011 4:34 pm

MdaSolution,

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

Code: Select all  Expand view  RUN
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...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests