NILKAMAL


hi!

how do i replace image from file

here is my code

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)\IMAGES\IMAGE.jpg"

* Get the image
lnImageHandle = TWAIN_AcquireNative(0,0)
replace image with lcFile
* 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

now problem is my image field show me a path (e.g C:\Documents and Settings\sony\My Documents\New Folder (2)\IMAGES\IMAGE.jpg ) but not actual image (when i click on image field)

is it possible to get image insted of path before i click




Re: image from file

Naomi Nosonovsky


Put an image control on the form and add two last lines of code in this procedure:

clear resources

thisform.Image1.Picture = m.lcFile






Re: image from file

NILKAMAL

thanx a lot it works now one more question how do i delete only image from this record






Re: image from file

Naomi Nosonovsky

replace Image with "" && in other words, remove the file reference from the table, Image field

clear resource

thisform.Image1.pictrure = ""

* perhaps also

thisform.Image1.visible = .f. && What's the point to show an empty image control

but then don't forget to set visible back to true if you do have a picture.





Re: image from file

NILKAMAL

thanks for your help

how do i bring image in my field ( field name is " image " and data type is memo(binary) ) instead of

thisform.image1.picture = lcfile

thanks





Re: image from file

Naomi Nosonovsky

thisform.image1.picture = myTable.Image

But you still have to refresh the picture yourself, e.g. as far as I know, you can not simply bound the image to the memo field. Somebody correct me, please, if I'm wrong.





Re: image from file

NILKAMAL

thanks for your help

i have employee table with photo field ( data type is memo(binaray) now i am trying to do is take image from webcame and save for employee photo field

thanks





Re: image from file

Naomi Nosonovsky

In the method which is called by navigation methods you may put the code I gave you, e.g.

clear resources

thisform.Image1.Picture = MyTable.MyImageFilePath

You probably can put it in the Refresh method of the form, but if you have a different method, say, RefreshForm as I do, this would be a better place.





Re: image from file

NILKAMAL

i try but it says image proprerities not found

as per you say before i get image in form in image control but i want to save with record so when i pull emplyoee record i get image too

thanks for your help





Re: image from file

Naomi Nosonovsky

I'm sorry, but I think we're going in circles here. When you created an image file, save it in the Employees table using replace command, e.g. replace MyImageField with (m.lcFullPathImageFile) in Employees

And when you're showing the employee record, if you have saved file, then show it using the code in the previous messages, but if your image field for this employee is empty, you may run the code you had and showed in other thread (I'm not familiar with that particular thing).

Hopefully this is clear now.