Page 1 of 2

path of an image

Posted: Wed Jul 27, 2011 7:07 pm
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 ?

Re: path of an image

Posted: Wed Jul 27, 2011 7:48 pm
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

Re: path of an image

Posted: Wed Jul 27, 2011 9:53 pm
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 ?

Re: path of an image

Posted: Wed Jul 27, 2011 10:42 pm
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:

Re: path of an image

Posted: Thu Jul 28, 2011 1:35 am
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.

Re: path of an image

Posted: Thu Jul 28, 2011 2:04 am
by hua
Rao,
Do you have any examples on how to use memo fields to deal with images?

TIA.

Re: path of an image

Posted: Thu Jul 28, 2011 2:41 am
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.

Re: path of an image

Posted: Thu Jul 28, 2011 4:35 am
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?

Re: path of an image

Posted: Thu Jul 28, 2011 5:19 am
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.

Re: path of an image

Posted: Thu Jul 28, 2011 8:41 am
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

Re: path of an image

Posted: Thu Jul 28, 2011 9:43 am
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.

Re: path of an image

Posted: Thu Jul 28, 2011 1:06 pm
by hua
Any snippet of how to do it with, let say, TImage control?

TIA

Re: path of an image

Posted: Sat Jul 30, 2011 8:56 am
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

Re: path of an image

Posted: Fri Sep 02, 2011 3:16 pm
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

Re: path of an image

Posted: Fri Sep 02, 2011 4:34 pm
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"