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


> >
> > Hi Yousfi,
> >
> > Thanks for the help.
> > I think, I didn't explain clearly before.
> >
> > Here is what exactly I need.
> > I need a program that takes an image and adds some text to it, ideally I want to "extend" the height of the image, meaning if the image is 400x300, I want to make the output 400x380 for example where the lower 80 pix are white and the original image is in the top 300 and make sure image does not distort, (a circle has to stay circle not become an oval) then add the text to the lower 80.
> >
> > In the attachment, I added the images how I am expecting to be.
> >
> >
> > https://www.foxite.com/uploads/fd69826f-f9e5-4916-88b2-3ae1172ecb90.zip
> >
> > TIA,
> > Ravi.,
>
> Finally you want a small code that is
>
> LOCAL lcSource, lnWidth, lnHeight
> lcSource = GETPICT()
> IF EMPTY(lcSource)
>    RETURN
> ENDIF
> DO LOCFILE("System.App")
> 
> WITH _SCREEN.System.Drawing
> LOCAL loBmp AS xfcBitmap
> loBMP0=.bitmap.new(400,380)  &&as you want
> loBmp = .Bitmap.FromFile(lcSource) 
> logfx= .Graphics.FromImage(loBmp0) 
> logfx.clear(.color.white)
> lnWidth = loBmp.Width
> lnHeight = loBmp.Height
> logfx.drawimage(loBMP,0,0,400,300)  &&as you want
> ***************************
> *text
> ystring="Happy new year 2009"
>    loFont = .Font.New("tahoma", 24,  .FontStyle.BoldItalic)  &&adapt font,size,BI
> 	loSizeF = loGfx.MeasureString(ystring, loFont)
> 	loRectangleF =_screen.system.Drawing.RectangleF.New(10,300,loSizeF.Width, loSizeF.Height)   
> 	loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3)
> 	loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
> ********************
> 
> loBmp0.Save("c:\ravi.png", .Imaging.ImageFormat.Png)
> RUN /N "mspaint" c:\ravi.png
>  
>  endwith
>  retu
> 

>
>
> image 400x380
>
> for your personal us etry this
>
> local w,h
> w=400  &&image width
> h=380  &&image height
> delta=80  &&text zone
> 
> LOCAL lcSource, lnWidth, lnHeight
> lcSource = GETPICT()
> IF EMPTY(lcSource)
>    RETURN
> ENDIF
> DO LOCFILE("System.App")
> 
> 
> WITH _SCREEN.System.Drawing
> LOCAL loBmp AS xfcBitmap
> loBMP0=.bitmap.new(w,h)
> loBmp = .Bitmap.FromFile(lcSource) 
> logfx= .Graphics.FromImage(loBmp0) 
> logfx.clear(.color.white)
> lnWidth = loBmp.Width
> lnHeight = loBmp.Height
> logfx.drawimage(loBMP,0,0,w,h-delta)
> ***************************
> *text1
> ystring="Happy new year 2009"
>    loFont = .Font.New("tahoma", 24,  .FontStyle.BoldItalic)
> 	loSizeF = loGfx.MeasureString(ystring, loFont)
> 	loRectangleF =_screen.system.Drawing.RectangleF.New(10,h-delta,loSizeF.Width, loSizeF.Height)   
> 	loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3)
> 	loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
> **************************
> *text2
> LOCAL lcStyle
> lcStyle = "BI"
> ystring1="Meilleurs voeux 2009"
> xfont="Arial Black"
> xsize=24
> xBackcolor1=rgb(0,255,0)
> xbackcolor2=rgb(0,0,55)
> epaisseur=3
> *********************
> 	* Create a GraphicsPath object.  
> 	LOCAL loPath as xfcGraphicsPath
> 	loPath = .Drawing2D.GraphicsPath.New()
> lostyle=.FontStyle.Italic
> 	* Add the string with font,size, style and position.  
> 	loPath.AddString(ystring1, ;
> 		.FontFamily.New(xFont), ;
> 		lostyle, ;
> 		xsize, ;
> 		.Point.New(30,h-delta/2))
> 	* choice a pen
> 	LOCAL loPen as xfcPen
> 	loPen = .Pen.New(.Color.FromRGB(xBackColor1),epaisseur)
> 	* Draw around the outline of the path
> 	loGfx.DrawPath(loPen, loPath)
> 	* draw the original text 
> 	loGfx.FillPath(.SolidBrush.New(.Color.FromRGB(xBackColor2)), loPath)
> ********************
> loBmp0.Save("c:\ravi.png", .Imaging.ImageFormat.Png)
> RUN /N "mspaint" c:\ravi.png
>  
>  endwith
>  retu
> 

>
>
>
> regards

Thanks Yousfi, my ratings to you.

Ravi.,

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