Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: michael tjia
  Where is michael tjia?
 singapore
 Singapore
 michael tjia
 To: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 Tags
Subject: RE: question abt VFP Paint made by Mr Cesar
Thread ID: 227808 Message ID: 228450 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, May 19, 2009 6:12:56 AM         
   


> > Hi all
> >
> > I am facing an issue. So actually I am using VFP Paint made by Mr Cesar with some modifications. Now I have finished my project, but sometimes there is an error message that I have never faced before. “API call caused an exception”. I tried to google, but I still can’t figure it out. Any idea would be appreciated. Thanks a lot all
> >
> >
> > Thanks,
> >
> > Michael
> >
> >
> >
> > 
> > LOCAL loBmp AS xfcBitmap
> > LOCAL lotmpBmp AS xfcBitmap
> > LOCAL lotmpGfx AS xfcGraphics
> > LOCAL loRect AS xfcRectangle
> > LOCAL loBmpData AS xfcBitmapData
> > LOCAL lnWidth, lnHeight, nBytes, b, g, r, lnPos0
> > 
> > PUBLIC length
> > 
> > DIMENSION length(362)
> > 
> > x_centre=val(thisform.lblCorX.Caption)
> > y_centre=val(thisform.lblCorY.Caption)
> > x_start=val(thisform.lblMouseXMin.Caption)
> > x_end=val(thisform.lblMouseXMax.Caption)
> > y_start=val(thisform.lblMouseYMin.Caption)
> > y_end=val(thisform.lblMouseYMax.Caption)
> > var_length=0
> > x1=0
> > 
> > 	
> > WITH _SCREEN.System.Drawing
> > 
> > 	loBmp = Thisform.oMainBmp
> > 	lnWidth = loBmp.Width
> > 	lnHeight = loBmp.Height
> > 
> > 	lotmpBmp = .Bitmap.New(lnWidth, lnHeight)
> > 	lotmpGfx = _screen.System.Drawing.Graphics.FromImage(lotmpBmp)
> > 	lotmpGfx.DrawImage(loBmp,0,0,lnWidth,lnHeight)
> > 	
> > 	loRect = .Rectangle.New(0, 0, lnWidth, lnHeight)
> > 	loBmpData = lotmpBmp.LockBits(loRect, .Imaging.ImageLockMode.ReadWrite, ;
> > 	_screen.System.Drawing.Imaging.PixelFormat.Format24bppRGB)
> > 	nBytes = loBmpData.Width * loBmpData.Height * 3
> > 	
> > 	DIMENSION arr_r[loBmpData.Height+2,loBmpData.Width+2]
> > 	DIMENSION arr_g[loBmpData.Height+2,loBmpData.Width+2]
> > 	DIMENSION arr_b[loBmpData.Height+2,loBmpData.Width+2]
> > 	
> > 	hgt=loBmpData.Height
> > 	wdt=loBmpData.Width
> > 	
> > 	LOCAL lnSecs
> > 	lnSecs = SECONDS()
> > 
> > 		FOR i = 1 TO 45
> > 		var_length=0
> > 			FOR j =x_centre TO x_end				
> > 				WITH thisform
> > 					x2=round((j-x_centre)*(tan(dtor(i))),0)		
> > 					lnPos0 = loBmpData.Scan0 + (loBmpData.Stride *(y_centre-x2)) + (3 * j)
> > 					var_b = ASC(SYS(2600, lnPos0, 1))
> > 					var_g = ASC(SYS(2600, lnPos0 + 1, 1))
> > 					var_r = ASC(SYS(2600, lnPos0 + 2, 1))
> > 					IF var_r>200 AND var_g <140 AND var_b<140 AND  var_r<>var_g AND var_r<>var_b
> > 					length[i]=sqrt((j-x_centre)^2+(x2)^2)	
> > 					var_length=1	
> > 					EXIT for			
> > 					ENDIF		
> > 				ENDWITH							
> > 			NEXT					
> > 			IF var_length = 0 then
> > 				MESSAGEBOX('Please draw the lens again. Error on degree = '+alltrim(STR(i,3,0)),16,'Polycore DC')
> > 				return
> > 			ENDIF	
> > 		NEXT
> > 				
> > 		var_x=0
> > 		var_y=0
> > 		FOR i=46 TO 360
> > 		var_length=0
> > 			FOR j=x_centre TO x_end
> > 				WITH thisform
> > 					var_x=ROUND(((j-x_centre)*COS(DTOR(i-45)))-((j-x_centre)*SIN(DTOR(i-45))),0)
> > *!*						IF var_x<0
> > *!*						
> > *!*						messagebox(var_x)
> > *!*						ENDIF
> > 					
> > 					var_y=ROUND(((j-x_centre)*COS(DTOR(i-45)))+((j-x_centre)*SIN(DTOR(i-45))),0)
> > 					lnPos0 = loBmpData.Scan0 + (loBmpData.Stride *(y_centre-var_y)) + (3 * (x_centre+var_x))
> > 					var_b = ASC(SYS(2600, lnPos0, 1))
> > 					var_g = ASC(SYS(2600, lnPos0 + 1, 1))
> > 					var_r = ASC(SYS(2600, lnPos0 + 2, 1))
> > 					IF var_r>200 AND var_g <140 AND var_b<140 AND  var_r<>var_g AND var_r<>var_b
> > 						length[i]=SQRT((var_x)^2+((var_y))^2)
> > 						var_length=1	
> > 						EXIT for
> > 					ENDIF
> > 				ENDWITH		
> > 			ENDFOR	
> > 			IF var_length = 0 then
> > 				MESSAGEBOX('Please draw the lens again. Error on degree = '+alltrim(STR(i,3,0)),16,'Polycore DC')
> > 				return
> > 			ENDIF
> > 		ENDFOR
> > 	
> > 	lotmpBmp.UnlockBits(loBmpData)
> > 
> > ENDWITH
> > 
> > 
> > str_length=''
> > FOR i=1 TO 360
> > 	str_length=str_length+ALLTRIM(STR(i,3,0))+'    '+ALLTRIM(STR(ROUND((length[i]/thisform.txtMonitor.Value),2),7,2))+CHR(13)+CHR(10)
> > ENDFOR
> > 
> > STRTOFILE(str_length,'length.txt',0)
> > 

>
>
>
> you can be a little more specific please ?
> what form of vfpPaint,what version ? i suppose beforedraw method and lockbit function.....
>
> Dont rate please.its only for the pleasure to help.Give me only a feed back.
> Yousfi Benameur



Sorry for my late reply, I just came back from my leave. I don't know what is the version of the VFPPaint. I thought it just has 1 version only. I put above code in a button in the form vfppaint.scx. Do you have any idea? all the functions that Mr Cesar made work well. The problem just the function that I made by myself above.


Thanks,

Michael

ENTIRE THREAD

question abt VFP Paint made by Mr Cesar Posted by michael tjia @ 5/13/2009 10:48:21 AM
RE: question abt VFP Paint made by Mr Cesar Posted by Yousfi Benameur @ 5/13/2009 11:05:02 AM
RE: question abt VFP Paint made by Mr Cesar Posted by michael tjia @ 5/19/2009 6:12:56 AM
RE: question abt VFP Paint made by Mr Cesar Posted by Yousfi Benameur @ 5/19/2009 10:20:09 AM