Photo Images

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Photo Images

Post by franco » Tue Jun 18, 2019 5:41 pm

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
Franco Bushie
Canada

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Sat Jun 22, 2019 3:42 pm

To make it simple, does anyone know how to run the camera from inside an hmg program on a laptop.
Thanks, Franco
Franco Bushie
Canada

User avatar
andyglezl
Posts: 1160
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 73 times
Contact:

Post by andyglezl » Sat Jun 22, 2019 5:31 pm

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: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Mon Jun 24, 2019 3:17 pm

Thanks Andy.
I seen this before but could not find it. I will try to see how they did it.
Franco
Franco Bushie
Canada

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Sat Jun 29, 2019 11:40 pm

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.
Franco Bushie
Canada

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Sun Jun 30, 2019 9:46 am

I am getting close to making this work
I will post when working for thoughts.
Franco
Franco Bushie
Canada

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Mon Jul 01, 2019 5:51 pm

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
Franco Bushie
Canada

franco
Posts: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Tue Jul 30, 2019 4:28 am

Does anyone know the origin of camera.swf. I was just wondering if this is a safe program.
Thanks in advance Franco.
Franco Bushie
Canada

User avatar
mustafa
Posts: 836
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 120 times
Contact:

Post by mustafa » Wed Jul 31, 2019 9:45 am

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: 340
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Wed Jul 31, 2019 4:08 pm

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
Franco Bushie
Canada

Post Reply