Photo Images

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Photo Images

Post by franco »

Hi all, I have built a program that has up to 8 images for each Invoice.
the images are in the table for the invoice, image1,image2 etc, Right now I have a textbox in the edit screen to put the image name in
for each image. The jpg files are in a photo folder of the current dir. So when I take a picture I put the picture`s jpg name in the folder
and copy and past the name into the textbox which then update the table and image is correct.
Does anybody know how to, when using a tablet or laptop to have button beside the textbox to take a photo from inside the program and
automatically up date the textbox with photos name. This would save tons of time and no errors.
I thought I seen a camera image in the samples somewhere but can not locate.
Thanks in advance ..Franco
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

To make it simple, does anyone know how to run the camera from inside an hmg program on a laptop.
Thanks, Franco
All The Best,
Franco
Canada
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Photo Images

Post by andyglezl »

Hola Franco, quizá esto te sirva...
*-----------------------------------
Hi, Franco, maybe this will help ...

viewtopic.php?f=14&t=4862&hilit=camera+filato&start=20
Andrés González López
Desde Guadalajara, Jalisco. México.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

Thanks Andy.
I seen this before but could not find it. I will try to see how they did it.
Franco
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

This is what I am trying to do. REPOSTED BELOW WORKING
If you create a folder for this program copy this code to file and compile first
then copy any 2 jpg pictures to the PHOTO folder they will the show up in program.

Code: Select all

#INCLUDE <HMG.CH>

FUNCTION MAIN
PUBLIC INV := '1234', PHFOL := GETCURRENTFOLDER()+'\PHOTO\'
CREATEFOLDER(GETCURRENTFOLDER()+'\PHOTO\')
ACMOTORP()
RETURN

	FUNCTION ACMOTORP
		IF .NOT. ISWINDOWACTIVE(WIN_ACP) 
			DEFINE WINDOW WIN_ACP ;
			AT 30, 10 ;  //80 ;
			WIDTH GETDESKTOPWIDTH()-10  ;   // 1230 ;
			HEIGHT     GETDESKTOPHEIGHT()-27 ;
			TITLE 'AC MOTOR Q&A PHOTO SHEET ';
			MODAL ;
			FONT 'ARIAL' SIZE 9 ;    //NOMAXIMIZE ;NOMINIMIZE ;	
			BACKCOLOR (143,200,200) ;
			SYSMENU .T.

			
			DEFINE IMAGE IMAGE_1
				ROW	30
				COL	10
				HEIGHT	280
		        WIDTH	280
				PICTURE	PHFOL+INV+'-1.JPG' 
				STRETCH	.F.
			END IMAGE
			
			@ 315,10  LABEL LABEL_I1 VALUE 'PHOTO:1' WIDTH 55 TRANSPARENT ;
						TOOLTIP 'PHOTO NAME SHOULD BE IN THIS EXAMPLE 1234-1.JPG'
			@ 315,75  LABEL LABEL_1 VALUE 'TAKE PICTURE' WIDTH 60 HEIGHT 50 ;
						ACTION TAKEPICTURE('-1')
			
			DEFINE IMAGE IMAGE_2
				ROW	30
				COL	330
				HEIGHT	280
		        WIDTH	280
				PICTURE	PHFOL+INV+'-2.JPG'
				STRETCH	.F.
			END IMAGE
			
		@ 315,330  LABEL LABEL_I2 VALUE 'PHOTO:2' WIDTH 55 TRANSPARENT ;
						TOOLTIP 'PHOTO NAME SHOULD BE IN THIS EXAMPLE 1234-1.JPG'
		@ 315,395  LABEL LABEL_2  VALUE 'TAKE PICTURE'  WIDTH 60 HEIGHT 50 ;
						ACTION TAKEPICTURE('-2')

		END WINDOW
		ACTIVATE WINDOW WIN_ACP
		ELSE
			MSGBOX('IN USE')
		ENDIF	
		
		RETURN
		
	FUNCTION TAKEPICTURE(NAME) 
		IF NAME = '-1'
			//   WEBCAM TAKE PICURE HERE AND SHOULD BE SAVED AS PHFOL+INV+'-1.JPG'
			MSGBOX('TAKE PICTURE HERE *** SAVE AS SHOULD BE '+    PHFOL+INV+'-1.JPG')  //FIRST PICT
			WIN_ACP.IMAGE_2.REFRESH()
			ENDIF
		IF NAME = '-2'
			// WEBCAM  TAKE PICURE HERE AND SHOULD BE SAVED AS PHFOL+INV+'-2.JPG'
			MSGBOX('TAKE PICTURE HERE *** SAVE AS SHOULD BE '+    PHFOL+INV+'-2.JPG') //SECOND PICT
			WIN_ACP.IMAGE_2.REFRESH()
			ENDIF
	RETURN
To make this work would I need to add code like Mustafa`s webcam program or does someone have an idea for simpler code for
the lap top. I am stuck at this point.
Thanks in advance Franco
Last edited by franco on Mon Jul 01, 2019 6:16 pm, edited 4 times in total.
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

I am getting close to making this work
I will post when working for thoughts.
Franco
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

The following program now working, thanks to brain and all.
One problem the picture will still take if answer deny or no answer at all no camera .
If you take picture before anwering accept/deny it takes the accept /deny picture., or if you deny then snap the picture is blank.
I can not figure how to make Snap button invisable until accept is clicked.
The other is I can not figure how to pick a different camera. I think some had this working but I can not find.
Now that this is working I find it hard to take a picture with a laptop.

Code: Select all

#INCLUDE <HMG.CH>

FUNCTION MAIN
PUBLIC INV := '1234', PHFOL := GETCURRENTFOLDER()+'\PHOTO\'
CREATEFOLDER(GETCURRENTFOLDER()+'\PHOTO\')
ACMOTORP()
RETURN

	FUNCTION ACMOTORP
		IF .NOT. ISWINDOWACTIVE(WIN_ACP) 
			DEFINE WINDOW WIN_ACP ;
			AT 30, 10 ;  //80 ;
			WIDTH GETDESKTOPWIDTH()-10  ;   // 1230 ;
			HEIGHT     GETDESKTOPHEIGHT()-27 ;
			TITLE 'AC MOTOR Q&A PHOTO SHEET ';
			MODAL ;
			FONT 'ARIAL' SIZE 9 ;    //NOMAXIMIZE ;NOMINIMIZE ;	
			BACKCOLOR (143,200,200) ;
			SYSMENU .T.

			
			DEFINE IMAGE IMAGE_1
				ROW	30
				COL	10
				HEIGHT	280
		        WIDTH	280
				PICTURE	PHFOL+INV+'-1.JPG' 
				STRETCH	.F.
			END IMAGE
			
			@ 315,10  LABEL LABEL_I1 VALUE 'PHOTO:1' WIDTH 55 TRANSPARENT ;
						TOOLTIP 'PHOTO NAME SHOULD BE IN THIS EXAMPLE 1234-1.JPG'
			@ 315,75  BUTTON BUTTON_1 PICTURE 'CAMERA'  WIDTH 60 HEIGHT 50 ;
						ACTION TAKEPICTURE('-1')
			
			DEFINE IMAGE IMAGE_2
				ROW	30
				COL	330
				HEIGHT	280
		        WIDTH	280
				PICTURE	PHFOL+INV+'-2.JPG'
				STRETCH	.F.
			END IMAGE
			
		@ 315,330  LABEL LABEL_I2 VALUE 'PHOTO:2' WIDTH 55 TRANSPARENT ;
						TOOLTIP 'PHOTO NAME SHOULD BE IN THIS EXAMPLE 1234-1.JPG'
		@ 315,395  BUTTON BUTTON_2  PICTURE 'CAMERA'  WIDTH 60 HEIGHT 50  ; //VALUE 'TAKE PICTURE'  WIDTH 60 HEIGHT 50 ;
						ACTION TAKEPICTURE('-2')

		END WINDOW
		ACTIVATE WINDOW WIN_ACP
		ELSE
			MSGBOX('IN USE')
		ENDIF	
		
		RETURN
		
	FUNCTION TAKEPICTURE(NAME) 
		WEBCAM("WEBCAM","CAMERA.SWF","300","300")
		IF NAME = '-1'
			READYCAM(PHFOL+INV+'-1.JPG')
			WIN_ACP.IMAGE_1.PICTURE:= PHFOL+INV+'-1.JPG'
			WIN_ACP.IMAGE_1.REFRESH()
			ENDIF
		IF NAME = '-2'
			READYCAM(PHFOL+INV+'-2.JPG')
			WIN_ACP.IMAGE_2.PICTURE:= PHFOL+INV+'-2.JPG'
			WIN_ACP.IMAGE_2.REFRESH()
			ENDIF
	RETURN
		


FUNCTION READYCAM(PICT)

IF !ISWINDOWACTIVE(CAMFORM)                                                             
	DEFINE WINDOW CAMFORM AT 0, 0 WIDTH 330 HEIGHT 330 TITLE 'Shot Image ** Escape to Cancel'  ICON 'WEBCAM.ICO' MODAL  SYSMENU .F.
	ON KEY ESCAPE OF CAMFORM ACTION CAMFORM.RELEASE
	DEFINE ACTIVEX ACTIVEX2
        ROW     10
        COL     7
        WIDTH  300
        HEIGHT 230
        PROGID "SHELL.EXPLORER.2"
	END ACTIVEX
	DEFINE BUTTON BUTTON1
        ROW    250
        COL    120
        WIDTH  100
        HEIGHT 28
        ACTION SNAPSHOT(PICT)
        CAPTION "Snap Shot"
        FONTNAME "Arial"
        FONTSIZE 10
    END BUTTON
	END WINDOW

	CAMFORM.ACTIVEX2.OBJECT:NAVIGATE(GETCURRENTFOLDER()+"\WEBCAM.HTML")
	CAMFORM.CENTER
	CAMFORM.ACTIVATE
ELSE
	//CAMFORM.SETFOCUS
ENDIF
RETURN

FUNCTION SNAPSHOT(PICT)
  
CAMFORM.CAPTURE(PICT,15,7,300,220)  // ('TEST.jpg',15,7,500,420)
PLAYBEEP()
CAMFORM.RELEASE
RETURN

FUNCTION WEBCAM
PRIVATE   _cfile, _cimage, _cwidth, _cheight
PARAMETER _cfile, _cimage, _cwidth, _cheight
_cfile:=_cfile+".html"
TEXT TO FILE &_cfile
<html>
	<body style="overflow: hidden; margin: 0; padding: 0;"
		ondragstart="return false;" ondrop="return false;" oncontextmenu="return false;" onmousedown="return false;">
		<PARAM NAME="SCALE" VALUE="exactfit">
		<embed src="&_cimage" quality="high" type="application/x-shockwave-flash" width="100%" height="100%"
		allowScriptAccess="always" menu="false">
		</body>
</html>
ENDTEXT
RETURN
you must add CAMERA.SWF from brain`s or mustafa`s programs.
Thanks again, Franco
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

Does anyone know the origin of camera.swf. I was just wondering if this is a safe program.
Thanks in advance Franco.
All The Best,
Franco
Canada
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Photo Images

Post by mustafa »

Hello Franco
Your sample is very interesting

hello Mustafa, I have been using your picture taking example and it works perfectly , Thank You.
I was wondering, did you make the camera.swf file, and is there a way to use a different camera file
with your function.
Regards, Franco
the file "camera.swf" was provided by
the Brain sample

viewtopic.php?f=14&t=4862&hilit=camera+filato

Regards
Mustafa
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Photo Images

Post by franco »

Mustafa, thanks for response. Have you or anyone been able to get a cellphone to work as a usb camera. This would be better for what I am trying to
accomplish.
Franco
All The Best,
Franco
Canada
Post Reply