Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Two things I'd like to do with images
Message
 
À
08/02/2007 07:28:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01193534
Message ID:
01193560
Vues:
10
Hi Edgar as you're using VFP9 here's a possible solution to question #2.

I'd have to say it's no advisable to store images in vfp table as they tend to make the table grow in size very fast (a tipical picture with nowaday standard cameras goes around 1-2MBs). Instead you save the images in a folder and store the path to that folder in the VFP table but if you still decide to store it in the table here's you can do it using the VFP9 oledb provider. The field that stores the actual foto is a memo(binary) field which is only available to vfp9.

this code stores the picture in the table
_Screen.AddProperty([ConnString],[provider=vfpoledb.1;data source=c:\pruebas vfp\fotos\table1.dbf])

cFile = GETPICT("jpg,png,bmp,jepg,tif,tiff")

oSt = CREATEOBJECT("ADODB.Stream")

oSt.Open
oSt.Type=1 &&&& adTypeBinary
oSt.LoadFromFile(cFile)


Thisform.Coneccion()
	Thisform.Datos=Thisform.Getrs([Select * From table1 Where Numero=1])
Thisform.Desconectarse 

Thisform.Datos.AddNew

Thisform.Datos.Fields('Foto').Value=oSt.Read()


Thisform.Coneccion()
	Thisform.Updaters(Thisform.Datos,.t.,.t.)
Thisform.Desconectarse 
This code reads from the table and writes the file back to hard disk
_Screen.AddProperty([ConnString],[provider=vfpoledb.1;data source=c:\pruebas vfp\fotos\table1.dbf])

Thisform.Coneccion()
	Thisform.Datos=Thisform.Getrs([Select * From table1 Where numero=1])
Thisform.Desconectarse 

cFile=[c:\pruebas vfp\fotos\foto1.jpg]

IF FILE(cFile)
	ERASE &cFile
ENDIF 

oSt = CREATEOBJECT("ADODB.Stream")

oSt.Open
oSt.Type=1 &&&& adTypeBinary

oSt.Write(Thisform.Datos.Fields('Foto').Value)
oSt.SaveToFile(cFile)
oSt.Close()
Thisform.image1.Picture=cFile 
Thisform.Refresh 
Coneccion Method (creates an ADO connection)
LPARAMETERS cConnString
*---
*  Si no se pasa el string de conección como
*  parámetro se utiliza el string por defecto
*---
IF TYPE([cConnString])#"C"
	cConnString=_Screen.ConnString
ENDIF 

*--- Este Método establece una coneccion ADO
	This.Conn  = Createobject("adodb.connection")
	With This.Conn
		.Connectionstring = cConnString
		.CursorLocation = 3 &&&ADUSECLIENT &&&& 3
		.ConnectionTimeOut=60
		.Open
	ENDWITH
This is just an example and can be enhanced, notice the lack of an error management routine and some other stuff.

HTH

Enmanuel

>Hi, i'd like to do two things with images in my foxpro programs:
>
>1- I'd like to place a background image that always have the same size no matter the screen resolution.
>2- I'd like to save from a form a picture of someone in a record, for instance, the user clicks in a button, chooses the image and then save it.
>
>How can i do this?
I'm a mixture of Albert Einstein and Arnold Schwarzenegger. The only trouble is that I got Einstein's body and Schwarzenegger's brain
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform