Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: Ravi Kanth
  Where is Ravi Kanth?
 Hyderabad
 India
 Ravi Kanth
 Tags
Subject: RE: Text On Image
Thread ID: 209220 Message ID: 209283 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Friday, December 26, 2008 8:26:41 PM         
   


> >
> > Hi
> > you must as Anil said download the gdiplusX at the link indicated.
> > then run this program.gdiplusX.vcx must present anywhere on disc.
> >
> > set classlib to locfile('gdiplusX') addi
> > yform=createObject('asup')
> > yform.show
> > set classlib to
> > read events
> > return
> > *--Author Yousfi Benameur El Bayadh Algeria
> > *-- Time Stamp:   12/26/08 10:56:06 AM
> > *
> > DEFINE CLASS asup AS form
> > 	Top = 5
> > 	Left = 70
> > 	Height = 502
> > 	Width = 625
> > 	ShowWindow = 2
> > 	DoCreate = .T.
> > 	ShowTips = .T.
> > 	BorderStyle = 2
> > 	Caption = "Drawing text on image gdiplusX"
> > 	MaxButton = .T.
> > 	ybackground = .F.
> > 	Name = "Form1"
> > 
> > 	ADD OBJECT imgcanvas1 AS imgcanvas WITH ;
> > 		Anchor = 15, ;
> > 		Height = 468, ;
> > 		Left = 1, ;
> > 		MousePointer = 15, ;
> > 		Top = 0, ;
> > 		Width = 623, ;
> > 		Name = "Imgcanvas1"
> > 
> > 	ADD OBJECT command1 AS commandbutton WITH ;
> > 		Top = 470, ;
> > 		Left = 466, ;
> > 		Height = 25, ;
> > 		Width = 48, ;
> > 		Caption = "Picture", ;
> > 		Name = "Command1"
> > ADD OBJECT command2 AS commandbutton WITH ;
> > 		Top = 470, ;
> > 		Left = 520, ;
> > 		Height = 25, ;
> > 		Width = 48, ;
> > 		Caption = "Draw", ;
> > 		Name = "Command2"
> > 		
> > 	ADD OBJECT text1 AS textbox WITH ;
> > 		Height = 25, ;
> > 		Left = 21, ;
> > 		ToolTipText = "Put your text here-can change font,size ,style,emplacement in beforedraw", ;
> > 		Top = 471, ;
> > 		Width = 423, ;
> > 		Name = "Text1"
> > 
> > 	PROCEDURE Resize
> > 		this.text1.left=10
> > 		this.text1.width=350
> > 		this.text1.top=this.height-this.text1.height-10
> > 		this.command1.left=this.text1.left+this.text1.width+10
> > 		this.command1.top=this.text1.top
> > 		this.command2.top=this.text1.top
> > 		this.command2.left=this.command1.left+this.command1.width+10
> > 	ENDPROC
> > 
> > 	PROCEDURE imgcanvas1.beforedraw
> > 		LOCAL loGfx AS xfcGraphics
> > 
> > 		logfx=this.ogfx
> > 		 WITH _screen.system.Drawing
> > 		loGfx.SmoothingMode = .Drawing2D.SmoothingMode.AntiAlias 
> > 		 this.clear(.color.white)
> > 
> > 		if NOT EMPTY(THISFORM.ybackground)
> > 		loBmp= .bitmap.FromFile(thisform.ybackground)
> > 		loGfx.drawImage(loBMP,0,0,this.width,this.height)
> > 
> > 		endi
> > 
> > 		if not empty(thisform.text1.value)
> > 		ystring=allt(thisform.text1.value)
> > 		   loFont = .Font.New("tahoma",12,  .FontStyle.BoldItalic)
> > 			loSizeF = loGfx.MeasureString(ystring, loFont)
> > 			loRectangleF =_screen.system.Drawing.RectangleF.New((this.width-loSizeF.width-10)/2,this.height-loSizeF.height-5,loSizeF.Width, loSizeF.Height)
> > 			loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3)
> > 			loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
> > 
> > 		endi
> > 
> > 		ENDWITH
> > 
> > 		return
> > 	ENDPROC
> > 
> > 
> > 	PROCEDURE command1.Click
> > 		thisform.ybackground=getpict()
> > 		if not empty(thisform.ybackground)
> > 		thisform.imgcanvas1.draw()
> > 		endi
> > 	ENDPROC
> >    PROCEDURE command2.Click
> > 		thisform.imgcanvas1.draw()		
> > 	ENDPROC
> > 
> > 	
> > 	Procedure destroy
> > 	clea events
> > 	ENDPROC
> > 
> > 
> > ENDDEFINE
> > *
> > 

> > you can put any picture and any text on this image.
> > you can modify font,fontsize,fontstyle and position of text in the methos beforedraw.
> > Regards
>
> Hi Yousfi,
>
> Thanks for example.
> But what I need is, user just gives the picture path and text, the program will automatically creates the new image file adding the text at the bottom part of the image (ie., 400X300 is original image resolution, the new image will be 400X380 adding the text at the lower 80 pix by not distorting the original image)
>
> I was trying with Ceser examples, but no luck so far.
>
> Ravi.,

If you want to go far and fix the text position on the imgcanvas ,resize the image.. try this
https://www.foxite.com/uploads/44d8390f-ecfe-4545-b09a-8a243a28c91c.zip
Regards

ENTIRE THREAD

Text On Image Posted by Ravi Kanth @ 12/26/2008 8:14:58 AM
RE: Text On Image Posted by Anil Sharma @ 12/26/2008 8:53:22 AM
RE: Text On Image Posted by Ravi Kanth @ 12/26/2008 1:24:49 PM
RE: Text On Image Posted by Yousfi Benameur @ 12/26/2008 11:06:58 AM
RE: Text On Image Posted by Ravi Kanth @ 12/26/2008 1:23:54 PM
RE: Text On Image Posted by Yousfi Benameur @ 12/26/2008 4:24:28 PM
RE: Text On Image Posted by Ravi Kanth @ 12/27/2008 7:36:22 AM
RE: Text On Image Posted by Yousfi Benameur @ 12/28/2008 1:01:47 AM
RE: Text On Image Posted by Ravi Kanth @ 12/29/2008 5:22:01 AM
RE: Text On Image Posted by Merinissa Galapon @ 12/29/2008 6:47:17 AM
RE: Text On Image Posted by Ravi Kanth @ 12/29/2008 6:51:31 AM
RE: Text On Image Posted by Yousfi Benameur @ 12/26/2008 8:26:41 PM