NILKAMAL


hello!

is any way replace my image with include reeno or any field data

like i take image from my webcame and it store in one folder after that i use replace command so it save path in my field but when i replace that time image name want to change

here is my code below

DO [C:\Program Files\EZTwain\VFP\EZTwain.prg]
TWAIN_SelectImageSource(0)
* Get list of devices into memory
TWAIN_GetSourceList()
LOCAL lcFile, lnImageHandle, lnReply
lcFile = "C:\Documents and Settings\sony\My Documents\New Folder (2)\PHOTO\.BMP"
* Get the image
lnImageHandle = TWAIN_AcquireNative(0,0)
* Write the image to a disk file
lnReply = ;
TWAIN_WriteNativeToFilename(lnImageHandle,lcFile)

* Release the image handle
TWAIN_FreeNative(lnImageHandle)

* Check for errors
IF lnReply = 0
* image successfully written to file
ELSE
* something went wrong
ENDIF
clear resources
thisform.image1.picture = m.lcFile
REPLACE TABLE1.IMAGE WITH THISFORM.IMAGE1.Picture




Re: replace image with own name

Naomi Nosonovsky


Your question is unclear. What exactly would you like to do

Your last line REPLACE TABLE1.IMAGE WITH THISFORM.IMAGE1.Picture

should be changed to

replace Image with m.lcFile in Table1






Re: replace image with own name

NILKAMAL

thanks for ur reply

but i have another question.

i am using EZTwain program to take the image and once i take an image it is stored in a folder "photo" and i use the replace command and save the path in my field.now the problem is when i take another picture it gets stored in the same image instead of creating another image.

thanks






Re: replace image with own name

Naomi Nosonovsky

I think you should control lcFile algorithm yourself. You can use sequential numbers or you can use dtos(date()) as part of your file name if you only take one photo a day. In other words, make sure you create a unique lcFile variable before saving the picture into it.



Re: replace image with own name

NILKAMAL

thanks for your reply

how do i control lc file or use dtos cos i take more than 25 image a day

thanks





Re: replace image with own name

Naomi Nosonovsky

In this case I think you need to use sequential numbers.

In other words:

lcImageDir = "c:\My Image Directory\" && Use your image directory instead

lnFiles = adir(laFiles, m.lcImageDir + "Photo*.jpg") && How many images we already have

lcFile = strtran(m.lcImageDir + "Photo*.jpg","*", alltrim(str(m.lnFiles+1))) && this way we assign next number to the image





Re: replace image with own name

NILKAMAL

thanks a lot

it works , u r the best

thanks





Re: replace image with own name

Naomi Nosonovsky

You're welcome, glad to help.



Re: replace image with own name

NILKAMAL

hello!

i have one more problem everything is working fine but when i build exe file my lc file don't locate

thanks





Re: replace image with own name

Naomi Nosonovsky

How exactly do you define lcFile and are you getting an error from compiler or when you run the executable What does exactly the error say



Re: replace image with own name

NILKAMAL

thanks

my lc file =C:\Documents and Settings\sony\My Documents\New Folder (2)\PHOTO\.jpg

i get the error when i run exe file

it says

error writing jpeg file

unable to access this file C:\Documents and Settings\sony\My Documents\New Folder (2)\PHOTO\.4.jpg

thanks




Re: replace image with own name

Naomi Nosonovsky

Are you sure you want to use this complicated directory to store your image files I would rather create a new directory on c drive called Employee_Photos and store images there.

E.g. something like:

Code Snippet

local loError, llError, lcPhotoDir

lcPhotoDir = "c:\Employee_Photos"

llError = .f.

if not directory(m.lcPhotoDir)

try

md (m.lcPhotoDir) && Make Employee_Photos directory

catch to loError

llError = .t.

endtry

if m.llError && we were unable to create our photo directory - may need to exit at this point

return .f.

endif

endif

lcFile = addbs(m.lcPhotoDir) + "Photo" + m.lcNextNum + ".jpg" && where lcNextNum is defined using my previous code





Re: replace image with own name

NILKAMAL

thanks it works but still i get error in my twain prg cos when i run exe file " file 'twain_logfile.prg does not exist and all twain .prg does not exist

thanks





Re: replace image with own name

Naomi Nosonovsky

Did you include these two programs in your project I'm sorry, I have no experience with twain.



Re: replace image with own name

NILKAMAL

thanks for your help

now i create another fom with one extra image control and i pla on top of my image field (where i can see imge for that record )

but problem is i can see all other data but not image (but i can see path in image field and when i click next or previous buttton

it change path in image field but i can't see image)

thanks