GdiplusX blurs & halos on images and texts
I re publish this old post i put in Foxite for the gdiplusX lovers.
This post contains 3 codes:
1-Apply different blurs on an image and simulate effect
2-Apply shadows,halos on an image and workshop for all adjustings.
3-Apply shadows,halos,fonts,adjustings alpha channel(opacity),..on text.
- all forms shipped with capture capability & export to Mspaint.
-system.app and gdiplusX class are required (the code asks to point to in each case).
*before begin download the 3th image below used in code or put your own picture in code(1-2).
published on Foxite:http://www.foxite.com/archives/blursshadows-with-gdiplusx-0000230380.htm
Friday, June 05, 2009 8:31:48 AM
Click on code to select [then copy] -click outside to deselect
*1* blurring an image
*before begin download the 3th image below used in code.
Set Classlib To Locfile("gdiplusX.vcx",'vcx') AddI &&point mandatory o gdiplusX class
Publi oform
oform=Createobject("yblur_im")
Release Classlib gdiplusX
oform.Show
Read Events
Retu
*
Define Class yblur_im As Form
Height = 654
Width = 736
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "gdiPlusX samples: blur an image."
BackColor = Rgb(0,0,0)
Name = "form1"
Add Object imgcanvas1 As imgcanvas With ;
Anchor = 15, ;
Picture = "cube.jpg", ;
Stretch = 2, ;
Height = 576, ;
Left = 3, ;
Top = 0, ;
Width = 741, ;
Name = "Imgcanvas1"
Add Object container1 As ycontainer With ;
Top = 576, ;
Left = 108, ;
Width = 493, ;
Height = 61, ;
BackStyle = 0, ;
SpecialEffect = 0, ;
Name = "Container1"
Procedure Load
Declare Integer Sleep In kernel32 Integer
Endproc
Procedure Resize
This.container1.Top=This.Height-This.container1.Height-2
This.container1.Left=(This.Width-This.container1.Width)/2
This.imgcanvas1.Height=This.container1.Top-2
Endproc
Procedure imgcanvas1.beforedraw
If Empty(This.Picture)
Return .F.
Endif
With _Screen.System.drawing
logfx=This.ogfx
logfx.SmoothingMode = .Drawing2D.SmoothingMode.HighQuality
logfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic
logfx.PixelOffsetMode = .Drawing2D.PixelOffsetMode.HighQuality
Local loBmp As xfcBitmap
loBmp =.Bitmap.new(.Bitmap.fromfile(This.Picture))
logfx.Clear(.Color.White)
* Get the thumbnail with the desired size
Local loDestBmp As xfcImage
loDestBmp = loBmp.GetThumbnailImage(loBmp.Width/Thisform.container1.spinner1.Value, loBmp.Height/Thisform.container1.spinner1.Value)
* Draw the image, showing the intensity of the CYAN channel.
logfx.DrawImage(loDestBmp, This.rectangle)
Endwith
Endproc
Procedure destroy
clea events
endproc
Enddefine
*
*-- EndDefine: yblur_im
*************************************************
Define Class ycontainer As Container
Anchor=768
Top = 576
Left = 108
Width = 493
Height = 61
BackStyle = 0
SpecialEffect = 0
Name = "Container1"
Add Object command1 As CommandButton With ;
Top = 17, ;
Left = 12, ;
Height = 27, ;
Width = 84, ;
Caption = "Picture...", ;
BackColor = Rgb(0,255,0), ;
Name = "Command1"
Add Object spinner1 As Spinner With ;
Height = 25, ;
KeyboardHighValue = 40, ;
KeyboardLowValue = 1, ;
Left = 115, ;
SpinnerHighValue = 40.00, ;
SpinnerLowValue = 1.00, ;
ToolTipText = "Change spinner to increase blur effect", ;
Top = 19, ;
Width = 73, ;
BackColor = Rgb(255,255,0), ;
Value = 3, ;
Name = "Spinner1"
Add Object command2 As CommandButton With ;
Top = 19, ;
Left = 228, ;
Height = 27, ;
Width = 103, ;
Caption = "Animate Effect", ;
BackColor = Rgb(0,255,0), ;
Name = "Command2"
Add Object command21 As CommandButton With ;
Top = 19, ;
Left = 403, ;
Height = 27, ;
Width = 72, ;
Anchor = 6, ;
Picture = "..\", ;
Caption = "Save to ....", ;
TabIndex = 1, ;
PicturePosition = 1, ;
PictureSpacing = 1, ;
BackColor = Rgb(0,255,0), ;
Name = "Command21"
Add Object commondialog1 As OleControl With ;
oleclass="MSComDlg.CommonDialog.1",;
Top = 21, ;
Left = 360, ;
Height = 25, ;
Width = 37, ;
Name = "CommonDialog1"
Add Object label1 As Label With ;
AutoSize = .T., ;
BackStyle = 0, ;
Caption = "Factor", ;
Height = 17, ;
Left = 132, ;
Top = 4, ;
Width = 36, ;
Name = "Label1"
Procedure command1.Click
Thisform.imgcanvas1.Picture=Getpict()
Endproc
Procedure spinner1.Init
This.Value=1
Endproc
Procedure spinner1.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure command2.Click
If Empty(Thisform.imgcanvas1.Picture)
Return .F.
Endif
Thisform.container1.spinner1.Value=25
For i=1 To 24
Thisform.container1.spinner1.Value=Thisform.container1.spinner1.Value-1
Thisform.container1.spinner1.InteractiveChange()
Sleep(50)
Endfor
Endproc
Procedure command21.Click
If Empty(Thisform.imgcanvas1.Picture)
Return .F.
Endif
Local strFilter
strFilter = "JPEG|*.JPG|PNG|*.png|BMP|*.bmp|GIF|*.gif|EMF|*.emf|TIF|*.tif"
With Thisform.container1
.commondialog1.CancelError = .F.
.commondialog1.Filter = strFilter
.commondialog1.ShowSave
With Thisform.imgcanvas1.obmp
.Save(Thisform.container1.commondialog1.FileName)
Endwith
Endwith
Endproc
Enddefine
*
*-- EndDefine:ycontainer
********************
Click on code to select [then copy] -click outside to deselect
*2* building halo/shadow behind any image
*before begin download the 3th image below used in code.
Do Locfile("system.app","app","Where is system.app of gdiiplusX project ?") &&mandatory
Set Classlib To Locfile("gdiplusX.vcx","vcx","Where is gdiplusX.vcx of gdiplusX project ?") AddI &&mandatory
Publi oform
oform=Newobject("asup")
Release Classlib gdiplusX
oform.Show
Read Events
Retu
Define Class asup As Form
Height = 705
Width = 798
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "Halo effect on text"
MinWidth = 545
mode = 0
Name = "form1"
Add Object imgcanvas1 As imgcanvas With ;
Anchor = 15, ;
Picture = "cube.jpg", ;
Stretch = 2, ;
Height = 619, ;
Left = 9, ;
Top = 5, ;
Width = 783, ;
smoothingmode = 0, ;
Name = "Imgcanvas1"
Add Object container1 As ycontainer With ;
Top = 624, ;
Left = 72, ;
Width = 656, ;
Height = 73, ;
SpecialEffect = 0, ;
Name = "Container1"
Procedure Load
*--Author Yousfi Benameur El Bayadh Algeria
*--Time stamp mercredi 11 mai 2009; 14:36:00
*--Subject :Works on gdiplusX images and effects
*DO locfile("c:\System.app")
Endproc
Procedure Init
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
This.SetAll("mousepointer",15,"commandbutton")
This.SetAll("mousepointer",15,"spinner")
This.SetAll("mousepointer",15,"shape")
Endproc
Procedure Resize
This.container1.Top=This.Height-This.container1.Height-2
This.container1.Left=(This.Width-This.container1.Width)/2
Endproc
Procedure imgcanvas1.beforedraw
If Empty(This.Picture)
Return
Endi
Local loFont As xfcFont
With _Screen.System.Drawing
This.Clear()
* Create a bitmap in a fixed ratio to the original drawing area.
This.oGfx.Clear(.Color.fromRgb(Thisform.container1.yback.BackColor) )
Local loBmp As xfcBitmap
Local x
x=Thisform.container1.spinner5.Value
loBmp = .Bitmap.New(This.Width / x, This.Height / x)
* Create a GraphicsPath object.
Local loPath As xfcGraphicsPath
loPath = .Drawing2D.GraphicsPath.New()
rec0=.rectangle.New(Thisform.container1.spinner1.Value,Thisform.container1.spinner2.Value,This.Width-2*Thisform.container1.spinner1.Value,This.Height-2*Thisform.container1.spinner2.Value)
loPath.addRectangle(rec0)
* Get the graphics object for the image.
Local loGfx As xfcGraphics
loGfx = .Graphics.FromImage(loBmp)
* loGfx.clear(.color.fromRgb(thisform.container1.yback.backcolor) ) &&white)
* Create a matrix that shrinks the drawing output by the fixed ratio.
Local loMatrix As xfcMatrix
loMatrix = .Drawing2D.Matrix.New(1/x, 0, 0, 1/x, -1/x, -1/x)
* Choose an appropriate smoothing mode for the halo.
loGfx.smoothingmode = .Drawing2D.smoothingmode.AntiAlias
* Transform the graphics object so that the same half may be used for both halo and text output.
loGfx.Transform = loMatrix
* Using a suitable pen...
Local loPen As xfcPen
loPen = .Pen.New(.Color.fromRgb(Thisform.container1.Shape1.BackColor))
* Draw around the outline of the path
loGfx.DrawPath(loPen, loPath)
* and then fill in for good measure.
loGfx.FillPath( .SolidBrush.New(.Color.fromRgb(Thisform.container1.Shape1.BackColor)), loPath)
* setup the smoothing mode for path drawing
This.oGfx.smoothingmode = .Drawing2D.smoothingmode.AntiAlias
* and the interpolation mode for the expansion of the halo bitmap
This.oGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic
* expand the halo making the edges nice and fuzzy.
This.oGfx.DrawImage(loBmp, This.rectangle, 0, 0,loBmp.Width, loBmp.Height, .GraphicsUnit.Pixel)
* Redraw the original text
This.oGfx.FillPath(.SolidBrush.New(.Color.fromRgb(Thisform.container1.Shape1.BackColor)), loPath)
w=rec0.Width
h=rec0.Height
orec=.rectangle.New(Thisform.container1.spinner3.Value,Thisform.container1.spinner4.Value,w,h)
* Get the graphics object for the image.
This.oGfx.DrawImage(.Bitmap.fromfile(This.Picture),orec)
*******************
*text
Local loFont As xfcFont
Local loBrush As xfcLinearGradientBrush
Local loRectangleF As xfcRectangleF
Local loSizeF As xfcSizeF
ystring=Allt(Thisform.container1.edit1.Value)
loFont = .Font.New("Arial Black", 14, .FontStyle.BoldItalic)
loSizeF = loGfx.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.New(Thisform.container1.spinner6.Value,Thisform.container1.spinner7.Value,loSizeF.Width, loSizeF.Height)
loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3,.T.)
This.oGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
**********************
Endwith
Return
Endproc
Procedure Destroy
Clea Events
Endproc
Enddefine
*
*-- EndDefine: asup
**************************************************
Define Class ycontainer As Container
Add Object command3 As CommandButton With ;
Top = 11, ;
Left = 12, ;
Height = 27, ;
Width = 72, ;
backcolor=rgb(0,255,0),;
Caption = "Picture....", ;
Name = "Command3"
Add Object spinner1 As Spinner With ;
Height = 25, ;
KeyboardHighValue = 15, ;
KeyboardLowValue = 0, ;
Left = 96, ;
SpinnerHighValue = 15.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Adjust on X", ;
Top = 12, ;
Width = 60, ;
Value = 15, ;
Name = "Spinner1"
Add Object spinner2 As Spinner With ;
Height = 25, ;
KeyboardHighValue = 15, ;
KeyboardLowValue = 0, ;
Left = 95, ;
SpinnerHighValue = 15.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "adjust on y", ;
Top = 39, ;
Width = 60, ;
Value = 15, ;
Name = "Spinner2"
Add Object Shape1 As Shape With ;
Top = 31, ;
Left = 168, ;
Height = 25, ;
Width = 25, ;
ToolTipText = "Halo color", ;
BackColor = Rgb(0,0,0), ;
Name = "Shape1"
Add Object spinner3 As Spinner With ;
Height = 25, ;
KeyboardHighValue = 15, ;
KeyboardLowValue = 0, ;
Left = 221, ;
SpinnerHighValue = 15.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Adjust image x", ;
Top = 10, ;
Width = 60, ;
Value = 5, ;
Name = "Spinner3"
Add Object spinner4 As Spinner With ;
Height = 25, ;
KeyboardHighValue = 15, ;
KeyboardLowValue = 0, ;
Left = 220, ;
SpinnerHighValue = 15.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "adjust image y", ;
Top = 37, ;
Width = 60, ;
Value = 5, ;
Name = "Spinner4"
Add Object spinner5 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 30, ;
KeyboardLowValue = 1, ;
Left = 292, ;
SpinnerHighValue = 30.00, ;
SpinnerLowValue = 1.00, ;
ToolTipText = "adjust halo", ;
Top = 24, ;
Width = 48, ;
Value = 5, ;
Name = "Spinner5"
Add Object command4 As CommandButton With ;
Top = 23, ;
Left = 348, ;
Height = 27, ;
Width = 55, ;
Caption = "Capture", ;
ToolTipText = "Capture", ;
Name = "Command4"
Add Object yback As Shape With ;
Top = 42, ;
Left = 36, ;
Height = 25, ;
Width = 25, ;
ToolTipText = "Image Backcolor", ;
BackColor = Rgb(255,255,255), ;
Name = "yBack"
Add Object edit1 As EditBox With ;
Height = 61, ;
Left = 417, ;
Top = 5, ;
Width = 167, ;
Name = "Edit1"
Add Object spinner6 As Spinner With ;
Height = 24, ;
Increment = 5.00, ;
KeyboardLowValue = 0, ;
Left = 589, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "text X", ;
Top = 7, ;
Width = 49, ;
Value = 180, ;
Name = "Spinner6"
Add Object spinner7 As Spinner With ;
Height = 24, ;
Increment = 5.00, ;
Left = 584, ;
ToolTipText = "text Y", ;
Top = 41, ;
Width = 49, ;
Value = 50, ;
Name = "Spinner7"
Procedure command3.Click
Thisform.imgcanvas1.Picture=Getpict()
Thisform.imgcanvas1.Stretch=2
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner1.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner2.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure Shape1.Click
This.BackColor=Getcolor()
If Empty(This.BackColor)
This.BackColor=0
Endi
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner3.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner4.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner5.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure command4.Click
Thisform.imgcanvas1.obmp.toClipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure yback.Click
This.BackColor=Getcolor()
If Empty(This.BackColor)
This.BackColor=Rgb(255,255,255)
Endi
Thisform.imgcanvas1.Draw
Endproc
Procedure edit1.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure edit1.Init
TEXT to myvar noshow
The air is so fragrant, the light is so pure ...
5 juin 2009
ENDTEXT
This.Value=myvar
Endproc
Procedure spinner6.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner7.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Enddefine
*ENDDEFINE ycontainer
*****************************
Click on code to select [then copy] -click outside to deselect
*3* a gdiplusX texts workshop
Set Classlib To Locfile('gdiplusX','vcx',"where is gdiplud>X.vcx of gdiplusX project?")
Publi oform
oform=Newobject("asup")
Release Classlib gdiplusX
oform.Show
Read Events
Retu
*
Define Class asup As Form
BorderStyle = 3
Height = 700
Width = 647
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "gdiPlusX - text drawings revisited"
MaxButton = .F.
WindowState = 0
BackColor = Rgb(255,255,255)
yfont = .F.
Name = "form1"
Add Object imgcanvas1 As imgcanvas With ;
Anchor = 15, ;
BackStyle = 0, ;
Height = 100, ;
Left = 60, ;
Top = 7, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas1"
Add Object spinner1 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Mover Horizontallly", ;
Top = 135, ;
Width = 72, ;
Value = 6, ;
Name = "Spinner1"
Add Object spinner2 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Move Vertically", ;
Top = 161, ;
Width = 72, ;
Value = 2, ;
Name = "Spinner2"
Add Object imgcanvas2 As imgcanvas With ;
Anchor = 15, ;
BackStyle = 0, ;
Height = 100, ;
Left = 60, ;
Top = 113, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas2"
Add Object command1 As CommandButton With ;
Top = 75, ;
Left = 559, ;
Height = 27, ;
Width = 72, ;
Caption = "Capture", ;
Name = "Command1"
Add Object command2 As CommandButton With ;
Top = 186, ;
Left = 560, ;
Height = 27, ;
Width = 72, ;
Caption = "Capture", ;
Name = "Command2"
Add Object shape1 As Shape With ;
Top = 35, ;
Left = 12, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Main color", ;
BackColor = Rgb(0,255,0), ;
Name = "Shape1"
Add Object shape2 As Shape With ;
Top = 63, ;
Left = 11, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Shadow color", ;
BackColor = Rgb(0,0,255), ;
Name = "Shape2"
Add Object shape3 As Shape With ;
Top = 147, ;
Left = 12, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Main color", ;
BackColor = Rgb(255,128,0), ;
Name = "Shape3"
Add Object shape4 As Shape With ;
Top = 179, ;
Left = 13, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Shadow color", ;
BackColor = Rgb(100,100,100), ;
Name = "Shape4"
Add Object spinner3 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Mover Horizontallly", ;
Top = 25, ;
Width = 72, ;
Value = 11, ;
Name = "Spinner3"
Add Object spinner4 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Move Vertically", ;
Top = 49, ;
Width = 72, ;
Value = 8, ;
Name = "Spinner4"
Add Object imgcanvas3 As imgcanvas With ;
Anchor = 15, ;
Height = 100, ;
Left = 60, ;
Top = 222, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas3"
Add Object spinner5 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 6, ;
KeyboardLowValue = -6, ;
Left = 560, ;
SpinnerHighValue = 6.00, ;
SpinnerLowValue = -6.00, ;
ToolTipText = "Mover Horizontallly", ;
Top = 238, ;
Width = 72, ;
Value = 3, ;
Name = "Spinner5"
Add Object spinner6 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 3, ;
KeyboardLowValue = -3, ;
Left = 560, ;
SpinnerHighValue = 3.00, ;
SpinnerLowValue = -3.00, ;
ToolTipText = "Move Vertically", ;
Top = 269, ;
Width = 72, ;
Value = 1, ;
Name = "Spinner6"
Add Object shape5 As Shape With ;
Top = 275, ;
Left = 14, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Main color", ;
BackColor = Rgb(0,0,128), ;
Name = "Shape5"
Add Object command3 As CommandButton With ;
Top = 294, ;
Left = 560, ;
Height = 27, ;
Width = 72, ;
Caption = "Capture", ;
Name = "Command3"
Add Object imgcanvas4 As imgcanvas With ;
Anchor = 15, ;
Height = 100, ;
Left = 60, ;
Top = 327, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas4"
Add Object spinner8 As Spinner With ;
Height = 24, ;
Increment = 0.01, ;
InputMask = "999.999", ;
KeyboardHighValue = 1, ;
KeyboardLowValue = -1, ;
Left = 560, ;
SpinnerHighValue = 1.00, ;
SpinnerLowValue = -1.00, ;
ToolTipText = "Shear", ;
Top = 377, ;
Width = 72, ;
Value = 0.000, ;
Name = "Spinner8"
Add Object spinner9 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 6, ;
KeyboardLowValue = -6, ;
Left = 560, ;
SpinnerHighValue = 6.00, ;
SpinnerLowValue = -6.00, ;
ToolTipText = "Mover Vertically", ;
Top = 351, ;
Width = 72, ;
Value = 1, ;
Name = "Spinner9"
Add Object shape8 As Shape With ;
Top = 362, ;
Left = 12, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Main color", ;
BackColor = Rgb(64,0,128), ;
Name = "Shape8"
Add Object shape9 As Shape With ;
Top = 398, ;
Left = 12, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Shadow color", ;
BackColor = Rgb(128,0,64), ;
Name = "Shape9"
Add Object command5 As CommandButton With ;
Top = 401, ;
Left = 560, ;
Height = 27, ;
Width = 72, ;
Caption = "Capture", ;
Name = "Command5"
Add Object imgcanvas5 As imgcanvas With ;
Anchor = 15, ;
Height = 100, ;
Left = 62, ;
Top = 436, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas5"
Add Object spinner7 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Move Vertically", ;
Top = 481, ;
Width = 72, ;
Value = 5, ;
Name = "Spinner7"
Add Object spinner10 As Spinner With ;
Height = 24, ;
KeyboardHighValue = 20, ;
KeyboardLowValue = -20, ;
Left = 560, ;
SpinnerHighValue = 20.00, ;
SpinnerLowValue = -20.00, ;
ToolTipText = "Mover Horizontally", ;
Top = 455, ;
Width = 72, ;
Value = 5, ;
Name = "Spinner10"
Add Object shape6 As Shape With ;
Top = 469, ;
Left = 14, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Main color", ;
BackColor = Rgb(255,0,0), ;
Name = "Shape6"
Add Object shape7 As Shape With ;
Top = 500, ;
Left = 14, ;
Height = 25, ;
Width = 37, ;
ToolTipText = "Shadow color", ;
BackColor = Rgb(0,0,0), ;
Name = "Shape7"
Add Object command4 As CommandButton With ;
Top = 505, ;
Left = 560, ;
Height = 27, ;
Width = 72, ;
Caption = "Capture", ;
Name = "Command4"
Add Object imgcanvas6 As imgcanvas With ;
Anchor = 15, ;
Height = 157, ;
Left = 60, ;
Top = 539, ;
Width = 480, ;
smoothingmode = 0, ;
Name = "Imgcanvas6"
Add Object spinner11 As Spinner With ;
Height = 24, ;
Increment = 1.00, ;
KeyboardHighValue = 360, ;
KeyboardLowValue = 0, ;
Left = 3, ;
SpinnerHighValue = 360.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Rotate text 0-360°", ;
Top = 614, ;
Width = 56, ;
Value = 0, ;
Name = "Spinner11"
Add Object combo1 As ComboBox With ;
Height = 24, ;
Left = 12, ;
Top = 588, ;
Width = 40, ;
Name = "Combo1"
Add Object command6 As CommandButton With ;
Top = 2, ;
Left = 4, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command6"
Add Object command7 As CommandButton With ;
Top = 116, ;
Left = 9, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command7"
Add Object command8 As CommandButton With ;
Top = 239, ;
Left = 5, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command8"
Add Object command9 As CommandButton With ;
Top = 332, ;
Left = 8, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command9"
Add Object command10 As CommandButton With ;
Top = 438, ;
Left = 11, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command10"
Add Object command11 As CommandButton With ;
Top = 560, ;
Left = 5, ;
Height = 20, ;
Width = 48, ;
Caption = "Font", ;
Name = "Command11"
Add Object spinner12 As Spinner With ;
Height = 24, ;
Increment = 10.00, ;
KeyboardHighValue = 255, ;
KeyboardLowValue = 0, ;
Left = 558, ;
SpinnerHighValue = 255.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Opacity", ;
Top = 110, ;
Width = 73, ;
Value = 50, ;
Name = "Spinner12"
Add Object spinner13 As Spinner With ;
Height = 24, ;
Increment = 10.00, ;
KeyboardHighValue = 255, ;
KeyboardLowValue = 0, ;
Left = 563, ;
SpinnerHighValue = 255.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Opacity", ;
Top = -1, ;
Width = 72, ;
Value = 100, ;
Name = "Spinner13"
Add Object spinner14 As Spinner With ;
Height = 24, ;
Increment = 10.00, ;
KeyboardHighValue = 255, ;
KeyboardLowValue = 0, ;
Left = 562, ;
SpinnerHighValue = 255.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Opacity", ;
Top = 327, ;
Width = 72, ;
Value = 100, ;
Name = "Spinner14"
Add Object spinner15 As Spinner With ;
Height = 24, ;
Increment = 10.00, ;
KeyboardHighValue = 255, ;
KeyboardLowValue = 0, ;
Left = 561, ;
SpinnerHighValue = 255.00, ;
SpinnerLowValue = 0.00, ;
ToolTipText = "Opacity", ;
Top = 432, ;
Width = 72, ;
Value = 100, ;
Name = "Spinner15"
Add Object command12 As CommandButton With ;
Top = 533, ;
Left = 557, ;
Height = 27, ;
Width = 75, ;
Caption = "Anim", ;
Name = "Command12"
Procedure Init
This.SetAll("mousepointer",15,"commandbutton")
This.SetAll("mousepointer",15,"shape")
Thisform.yfont="Arial Black,22,B"
Endproc
Procedure imgcanvas1.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xtext="GdiPlusX library"
xcolormain=Thisform.shape1.BackColor
xcolorShadow=Thisform.shape2.BackColor
************************************
Local xoffset,yoffset
xoffset=Thisform.spinner3.Value
yoffset=Thisform.spinner4.Value
Local loFont As xfcFont
With _Screen.System.Drawing
This.Clear()
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
* Create a bitmap in a fixed ratio to the original drawing area.
Local loBmp As xfcBitmap
loBmp = .Bitmap.New(This.Width / 5, This.Height / 5)
* Create a GraphicsPath object.
Local loPath As xfcGraphicsPath
loPath = .Drawing2D.GraphicsPath.New()
loPath0 = .Drawing2D.GraphicsPath.New()
* Add the string in the chosen style.
loPath.AddString(xtext, ;
.FontFamily.New(xfont), ;
loStyle, ;
xsize, ;
.Point.New(xoffset, yoffset), ;
.StringFormat.GenericTypographic)
loPath0.AddString(xtext, ;
.FontFamily.New(xfont), ;
loStyle, ;
xsize, ;
.Point.New(0, 0), ;
.StringFormat.GenericTypographic)
* Get the graphics object for the image.
Local loGfx As xfcGraphics
loGfx = .Graphics.FromImage(loBmp)
loGfx.Clear(.Color.white)
* Create a matrix that shrinks the drawing output by the fixed ratio.
Local loMatrix As xfcMatrix
loMatrix = .Drawing2D.Matrix.New(1/5, 0, 0, 1/5, -1/5, -1/5)
* Choose an appropriate smoothing mode for the halo.
loGfx.smoothingmode = .Drawing2D.smoothingmode.AntiAlias
* Transform the graphics object so that the same half may be used for both halo and text output.
loGfx.Transform = loMatrix
* Using a suitable pen...
Local loPen As xfcPen
loPen = .Pen.New(.Color.FromRGB(xcolorShadow))
* Draw around the outline of the path
loGfx.DrawPath(loPen, loPath)
* and then fill in for good measure.
loGfx.FillPath( .SolidBrush.New(.Color.FromARGB(Thisform.spinner13.Value,xcolorShadow)), loPath)
* setup the smoothing mode for path drawing
This.oGfx.smoothingmode = .Drawing2D.smoothingmode.AntiAlias
* and the interpolation mode for the expansion of the halo bitmap
This.oGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic
* expand the halo making the edges nice and fuzzy.
This.oGfx.DrawImage(loBmp, This.Rectangle, 0, 0, ;
loBmp.Width, loBmp.Height, .GraphicsUnit.Pixel)
* Redraw the original text
This.oGfx.FillPath(.SolidBrush.New(.Color.FromRGB(xcolormain)), loPath0)
Endwith
Return
Endproc
Procedure imgcanvas1.Setup
This.AddProperty("yfont","Arial Black,48,B")
Endproc
Procedure spinner1.InteractiveChange
Thisform.imgcanvas1.Draw
Thisform.imgcanvas2.Draw
Endproc
Procedure spinner2.InteractiveChange
Thisform.imgcanvas1.Draw
Thisform.imgcanvas2.Draw
Endproc
Procedure imgcanvas2.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xtext="GdiPlusX library"
xBackcolor1=Thisform.shape4.BackColor
xbackcolor2=Thisform.shape3.BackColor
epaisseur=4
*********************
Local loFont As xfcFont
With _Screen.System.Drawing
This.Clear(.Color.white)
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
* Create a GraphicsPath object.
Local loPath As xfcGraphicsPath
loPath = .Drawing2D.GraphicsPath.New()
loPath0 = .Drawing2D.GraphicsPath.New()
* Add the string in the chosen style.
loPath0.AddString(xtext, ;
.FontFamily.New(xfont), ;
loStyle, ;
xsize, ;
.Point.New(0, 0))
* Add the string in the chosen style.
loPath.AddString(xtext, ;
.FontFamily.New(xfont), ;
loStyle, ;
xsize, ;
.Point.New(Thisform.spinner1.Value, Thisform.spinner2.Value))
* Using a suitable pen...
Local loPen As xfcPen
loPen = .Pen.New(.Color.FromRGB(xBackcolor1),epaisseur)
* Choose an appropriate smoothing mode for the border.
This.oGfx.smoothingmode = .Drawing2D.smoothingmode.AntiAlias
* Draw around the outline of the path
*This.oGfx.DrawPath(loPen, loPath)
This.oGfx.FillPath(.SolidBrush.New(.Color.FromARGB(Thisform.spinner12.Value,xBackcolor1)), loPath)
* Redraw the original text
This.oGfx.FillPath(.SolidBrush.New(.Color.FromRGB(xbackcolor2)), loPath0)
Endwith
Return
Endproc
Procedure imgcanvas2.Setup
This.AddProperty("yfont","Arial Black,48,B")
Endproc
Procedure command1.Click
Thisform.imgcanvas1.oBmp.toclipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure command2.Click
Thisform.imgcanvas2.oBmp.toclipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure shape1.Click
This.BackColor=Getcolor()
Thisform.imgcanvas1.Draw
Endproc
Procedure shape2.Click
This.BackColor=Getcolor()
Thisform.imgcanvas1.Draw
Endproc
Procedure shape3.Click
This.BackColor=Getcolor()
Thisform.imgcanvas2.Draw
Endproc
Procedure shape4.Click
This.BackColor=Getcolor()
Thisform.imgcanvas2.Draw
Endproc
Procedure spinner3.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner4.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure imgcanvas3.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xtext="GdiplusX library"
xBackColor=Thisform.shape5.BackColor
**************************************
Local loFont As xfcFont
Local loFontFamily As xfcFontFamily
With _Screen.System.Drawing
This.Clear()
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
loFont = .Font.New(xfont,xsize, loStyle)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackColor)), ;
This.Rectangle)
This.oGfx.TranslateTransform(Thisform.spinner5.Value,Thisform.spinner6.Value)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromRGB(This.Parent.BackColor)), ;
This.Rectangle)
This.oGfx.ResetTransform()
Endwith
Return
Endproc
Procedure imgcanvas3.Setup
This.AddProperty("yfont","Arial Black,48,B")
Endproc
Procedure spinner5.InteractiveChange
Thisform.imgcanvas3.Draw
Endproc
Procedure spinner6.InteractiveChange
Thisform.imgcanvas3.Draw
Endproc
Procedure shape5.Click
This.BackColor=Getcolor()
Thisform.imgcanvas3.Draw
Endproc
Procedure command3.Click
Thisform.imgcanvas3.oBmp.toclipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure imgcanvas4.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xBackcolor1=Thisform.shape8.BackColor
xbackcolor2=Thisform.shape9.BackColor
xtext="GdiplusX library"
lnShear =Thisform.spinner8.Value
***********************************
Local loFont As xfcFont
Local loFontFamily As xfcFontFamily
Local loMatrix As xfcMatrix
With _Screen.System.Drawing
This.Clear()
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
loFont = .Font.New(xfont ,xsize, loStyle)
loFontFamily = .FontFamily.New(xfont)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackcolor1)), ;
This.Rectangle)
Local lnCy, lnLineHeight, lnLineAscent, lnLineSpacing
lnLineAscent = loFontFamily.GetCellAscent(loStyle)
lnLineSpacing = loFontFamily.GetLineSpacing(loStyle)
lnLineHeight = loFont.GetHeight(This.oGfx)
lnCy = lnLineHeight * lnLineAscent / lnLineSpacing
*lnShear = Thisform.Spinner3.Value
loMatrix = .Drawing2D.Matrix.New()
loMatrix.Shear(lnShear, 0)
loMatrix.Scale(1, -1)
This.oGfx.MultiplyTransform(loMatrix)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromARGB(Thisform.spinner14.Value,xbackcolor2)), ;
.PointF.New(0 + (-0.82 * lnLineHeight * lnShear) , -(lnCy*2)-1-Thisform.spinner9.Value ))
*This.oGfx.DrawString(xText, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackcolor2)), ;
.PointF.New(0, -(lnCy*2)-1-thisform.spinner7.value))
This.oGfx.ResetTransform()
Endwith
Return
Endproc
Procedure imgcanvas4.Setup
This.AddProperty("yfont","Arial Black,28,BI")
Endproc
Procedure spinner8.InteractiveChange
Thisform.imgcanvas4.Draw
Endproc
Procedure spinner9.InteractiveChange
Thisform.imgcanvas4.Draw
Endproc
Procedure shape8.Click
This.BackColor=Getcolor()
Thisform.imgcanvas4.Draw
Endproc
Procedure shape9.Click
This.BackColor=Getcolor()
Thisform.imgcanvas4.Draw
Endproc
Procedure command5.Click
Thisform.imgcanvas4.oBmp.toclipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure imgcanvas5.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xBackcolor1=Thisform.shape6.BackColor
xbackcolor2=Thisform.shape7.BackColor
xtext="GdiplusX "
***********************************
Local loFont As xfcFont
Local loFontFamily As xfcFontFamily
Local loMatrix As xfcMatrix
With _Screen.System.Drawing
This.Clear()
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
loFont = .Font.New(xfont ,xsize, loStyle)
loFontFamily = .FontFamily.New(xfont)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromARGB(Thisform.spinner15.Value,xbackcolor2)), ;
.PointF.New(0+Thisform.spinner10.Value , 0+Thisform.spinner7.Value ) )
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackcolor1)), ;
This.Rectangle)
*This.oGfx.DrawString(xText, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackcolor2)), ;
.PointF.New(0, -(lnCy*2)-1-thisform.spinner7.value))
Endwith
Return
Endproc
Procedure imgcanvas5.Setup
This.AddProperty("yfont","Arial Black,48,BI")
Endproc
Procedure spinner7.InteractiveChange
Thisform.imgcanvas5.Draw
Endproc
Procedure spinner10.InteractiveChange
Thisform.imgcanvas5.Draw
Endproc
Procedure shape6.Click
This.BackColor=Getcolor()
Thisform.imgcanvas5.Draw
Endproc
Procedure shape7.Click
This.BackColor=Getcolor()
Thisform.imgcanvas5.Draw
Endproc
Procedure command4.Click
Thisform.imgcanvas5.oBmp.toclipboard()
Run/n3 mspaint
Inkey(2)
loShell=Createobject("wscript.shell")
loShell.sendKeys("^{v}")
Endproc
Procedure imgcanvas6.Setup
This.AddProperty("nCenterRotate",0)
This.AddProperty("yfont","Arial Black,28,B")
Endproc
Procedure imgcanvas6.beforedraw
Local lcStyle,xfont,xsize
xfont=Getwordnum(This.yfont,1,',')
xsize=Val(Getwordnum(This.yfont,2,","))
lcStyle=Getwordnum(This.yfont,3,",")
xBackcolor1=Rgb(0,255,0)
xtext="GdiplusX "
**********
Local loFont As xfcFont
Local loFontFamily As xfcFontFamily
Local loMatrix As xfcMatrix
With _Screen.System.Drawing
This.Clear()
Do Case
Case lcStyle == "B"
loStyle = .FontStyle.Bold
Case lcStyle == "I"
loStyle = .FontStyle.Italic
Case lcStyle == "BI"
loStyle = .FontStyle.BoldItalic
Otherwise
loStyle = .FontStyle.Regular
Endcase
loFont = .Font.New(xfont ,xsize, loStyle)
loFontFamily = .FontFamily.New(xfont)
loRect=.Rectangle.New( This.Width/2,This.Height/2,This.Width/2,This.Height/2)
This.oGfx.DrawString(xtext, loFont, ;
.SolidBrush.New(.Color.FromRGB(xBackcolor1) ), ;
loRect)
Local loMatrix As xfcMatrix
Local loPointF As xfcPointF
With _Screen.System.Drawing
loMatrix = .Drawing2D.Matrix.New()
loPointF = _Screen.System.Drawing.PointF.New(This.Width / 2, This.Height / 2)
loMatrix.RotateAt(This.nCenterRotate, loPointF)
This.oGfx.MultiplyTransform(loMatrix)
This.oGfx.DrawImage(This.oBmp, This.Rectangle)
Endwith
This.nCenterRotate = 0
Endwith
Return
Endproc
Procedure spinner11.InteractiveChange
With Thisform.imgcanvas6
If Thisform.combo1.Value=1
.nCenterRotate = +1
Else
.nCenterRotate = -1
Endi
If Abs(.nCenterRotate)>=359
.nCenterRotate=0
Endi
.Draw()
Endwith
Endproc
Procedure combo1.Init
This.AddItem("+")
This.AddItem("-")
This.ListIndex=1
This.Value=2
This.Style=2
Endproc
Procedure command6.Click
Thisform.imgcanvas1.yfont=Getfont()
Thisform.imgcanvas1.Draw
*xfont=GETWORDNUM(thisform.yfont,1,',')
*xsize=GETWORDNUM(thisform.yfont,2,",")
*lcstyle=GETWORDNUM(thisform.yfont,3,",")
*MESSAGEBOX(thisform.yfont+CHR(13)+xfont+CHR(13)+xsize+CHR(13)+lcstyle)
Endproc
Procedure command7.Click
Thisform.imgcanvas2.yfont=Getfont()
Thisform.imgcanvas2.Draw
Endproc
Procedure command8.Click
Thisform.imgcanvas3.yfont=Getfont()
Thisform.imgcanvas3.Draw
Endproc
Procedure command9.Click
Thisform.imgcanvas4.yfont=Getfont()
Thisform.imgcanvas4.Draw
Endproc
Procedure command10.Click
Thisform.imgcanvas5.yfont=Getfont()
Thisform.imgcanvas5.Draw
Endproc
Procedure command11.Click
Thisform.imgcanvas6.yfont=Getfont()
Thisform.imgcanvas6.Draw
Endproc
Procedure spinner12.InteractiveChange
Thisform.imgcanvas2.Draw
Endproc
Procedure spinner13.InteractiveChange
Thisform.imgcanvas1.Draw
Endproc
Procedure spinner14.InteractiveChange
Thisform.imgcanvas4.Draw
Endproc
Procedure spinner15.InteractiveChange
Thisform.imgcanvas5.Draw
Endproc
Procedure command12.Click
Local gnLower,gnUpper
Declare Integer Sleep In WIN32API Integer
For k=1 To 2
gnLower = 1
gnUpper = 16777000
For i=0 To 255
Thisform.shape6.BackColor= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)
Thisform.spinner15 .Value=i
Thisform.spinner15 .InteractiveChange
Sleep(20)
Endfor
For i=-20 To 20
Thisform.shape6.BackColor= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)
Thisform.spinner10 .Value=i
Thisform.spinner10 .InteractiveChange
Sleep(20)
Endfor
For i=-20 To 20
Thisform.shape6.BackColor= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)
Thisform.spinner7 .Value=i
Thisform.spinner7 .InteractiveChange
Sleep(20)
Endfor
Endfor
Endproc
Procedure Destroy
Clea Events
Endproc
Enddefine
*
*-- EndDefine: asup
************************
*Important:*the code above is tested on visual foxpro 9 sp2-under windows 10 pro