Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ISSUE: PictureVal and LoadPicture
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Titre:
ISSUE: PictureVal and LoadPicture
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01040817
Message ID:
01040817
Vues:
67
Performing this program is seen that LOADPICTURE() it is not practically usable with PictureVal.
Even if LoadPicture() remains a slow code,
the problem is not in LoadPicture(), but in the code that set PictureVal to the object.
if you split the set action in two phases,
pictureObject=LOADPICTURE()
 .PictureVal=M.pictureObject
the second require the 99.9% of the time.

With images 3200x3200,
the time of loading and the use of resources it becomes exponential.
This doesn't happen with a direct (FILETOSTR()) loading, and therefore
I have to suppose that something is not done well.
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form


	Top = -2
	Left = 0
	ScrollBars = 3
	DoCreate = .T.
	Caption = "Set PictureVal"
	Name = "Form1"


	ADD OBJECT image1 AS image WITH ;
		Top = 30, ;
		Name = "Image1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 4, ;
		Left = 94, ;
		Height = 20, ;
		Width = 107, ;
		Caption = "FILETOSTR", ;
		Name = "Command1"


	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 4, ;
		Left = 206, ;
		Height = 20, ;
		Width = 107, ;
		Caption = "LOADPICTURE", ;
		Name = "Command2"


	ADD OBJECT spinner1 AS spinner WITH ;
		Height = 24, ;
		Increment =   0.00, ;
		KeyboardHighValue = 1600, ;
		KeyboardLowValue = 100, ;
		Left = 4, ;
		SpinnerHighValue = 1600.00, ;
		SpinnerLowValue = 100.00, ;
		Top = 2, ;
		Width = 86, ;
		Value = 1600, ;
		Name = "Spinner1"


	PROCEDURE bmpblanksquare
		LPARAMETERS nSize,fileName
		* build a bmp 24bit nSize x nSize blank
		PRIVATE LineSize,BMPSize,FileSize,hFile,nLine
		LineSize	= 3*m.nSize-3*m.nSize%4
		BMPSize		=m.LineSize*m.nSize
		FileSize	=6+4+4+40+m.BMPSize
		hFile=FCREATE(m.fileName)
		FWRITE(m.hFile,"BM")						&& 2
		FWRITE(m.hFile,BINTOC(m.FileSize,"RS"))		&& 4
		FWRITE(m.hFile,0H00000000)					&& 4
		FWRITE(m.hFile,BINTOC(6+4+4+40,"RS"))		&& 4
		FWRITE(m.hFile,BINTOC(40,"RS"))				&& 4
		FWRITE(m.hFile,BINTOC(m.nSize,"RS"))		&& 4
		FWRITE(m.hFile,BINTOC(m.nSize,"RS"))		&& 4
		FWRITE(m.hFile,BINTOC(1,"2RS"))				&& 4
		FWRITE(m.hFile,BINTOC(24,"2RS"))			&& 4
		FWRITE(m.hFile,BINTOC(0,"RS"))				&& 4
		FWRITE(m.hFile,BINTOC(0,"RS"))				&& 4
		FWRITE(m.hFile,BINTOC(m.BMPSize,"RS"))		&& 4
		FWRITE(m.hFile,REPLICATE(BINTOC(0,"RS"),4))	&& 4*4
		FOR nLine=1 TO m.nSize
			=FWRITE(m.hFile,REPLICATE(0HFFFFFF,m.nSize))
			=FWRITE(m.hFile,REPLICATE(0H00,-3*m.nSize%4))	&& 32 bit align
		NEXT
		FCLOSE(m.hFile)
	ENDPROC


	PROCEDURE image1.Destroy
		ERASE (this.Tag)
	ENDPROC


	PROCEDURE image1.Init
		this.Tag = ADDBS(SYS(2023))+FORCEEXT(SYS(2015),"BMP")
	ENDPROC

	PROCEDURE command1.Click
		PRIVATE tStart
		ERASE (thisform.Image1.Tag)
		tStart=SECONDS()
		THISFORM.BMpBlankSquare(thisform.Spinner1.Value,thisform.Image1.Tag)
		DEBUGOUT SECONDS()-tStart
		tStart=SECONDS()
		thisform.Image1.PictureVal = FILETOSTR(thisform.Image1.Tag)
		MESSAGEBOX(SECONDS()-m.tStart,0,"Show Binary File",2000)
	ENDPROC


	PROCEDURE command2.Click
		PRIVATE tStart
		ERASE (thisform.Image1.Tag)
		THISFORM.BMpBlankSquare(thisform.Spinner1.Value,thisform.Image1.Tag)
		tStart=SECONDS()
		thisform.Image1.PictureVal = LOADPICTURE(thisform.Image1.Tag)
		MESSAGEBOX(SECONDS()-m.tStart,0,"Show LOADPICTURE Object",2000)
	ENDPROC


	PROCEDURE spinner1.Valid
		thisform.Image1.Move(0,30,m.this.Value,m.this.Value)
	ENDPROC


	PROCEDURE spinner1.DownClick
		NODEFAULT 
		this.Value=MAX(INT(this.value/2),INT(THIS.SpinnerLowValue))
	ENDPROC


	PROCEDURE spinner1.UpClick
		NODEFAULT 
		this.Value=MIN(INT(this.value*2),INT(THIS.SpinnerHighValue))
	ENDPROC

ENDDEFINE
Répondre
Fil
Voir

Click here to load this message in the networking platform