Drawing on top level form with gdiplusX and native vfp

Published on by Yousfi Benameur

*this code show how to draw on top level form surface with the form hwnd.

*the drawing can be made with the form hwnd as follow:

with thisform

If .ShowWindow= 2
.yhwnd = GetWindow(.HWnd, GW_CHILD)
Else
.yhwnd= Thisform.HWnd &&_vfp.hwnd
Endif

endwith


*these drawings can be achieved from vfp native functions or by gdiplusX
*show floodfill API effect (pick a color and pset on area to floodfill it as mspaint)
*show drawings as curves (sinusoides), as text with gradientbrush....
*the image: ypalette.jpg is encoded with strconv(), function ans restored as pictureVAl image property.

can download this zip form more informations

http://www.foxite.com/downloads/default.aspx?id=223

 

*1*

*begin code
Publi yform
yform=Newobject("ytlf")
yform.Show
Read Events

*
Define Class ytlf As Form
Top = 30
Left = 108
Height = 547
Width = 853
ShowWindow = 2
Caption = "MouseDown to floodFill for top level form-"
MaxButton = .F.
ycolor = .F.
yhwnd = .F.
ogr = .F.
Name = "form1"

Add Object image1 As Image With ;
Picture = "ypalette.jpg", ;
Stretch = 2, ;
Height = 174, ;
Left = 32, ;
MousePointer = 15, ;
Top = 20, ;
Width = 268, ;
Name = "Image1"

Add Object label1 As Label With ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 10, ;
Alignment = 2, ;
Caption = "", ;
Height = 18, ;
Left = 151, ;
Top = 209, ;
Width = 2, ;
ForeColor = Rgb(0,0,255), ;
Name = "Label1"

Add Object command1 As CommandButton With ;
Top = 492, ;
Left = 130, ;
Height = 37, ;
Width = 134, ;
backcolor=rgb(0,255,0),;
Caption = "GdiplusX-Re click me !", ;
Name = "Command1"

Add Object command2 As CommandButton With ;
Top = 492, ;
Left = 564, ;
Height = 25, ;
Width = 72, ;
FontBold = .T., ;
FontSize = 12, ;
Caption = "Clear", ;
ForeColor = Rgb(255,0,0), ;
backcolor=rgb(0,255,0),;
Name = "Command2"

Add Object command3 As CommandButton With ;
Top = 492, ;
Left = 7, ;
Height = 37, ;
Width = 120, ;
backcolor=rgb(0,255,0),;
Caption = "Native drawings", ;
Name = "Command3"

Add Object ylab As Label With ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 10, ;
Caption = "", ;
Height = 18, ;
Left = 684, ;
Top = 492, ;
Width = 2, ;
ForeColor = Rgb(176,0,88), ;
Name = "yLab"

Add Object command5 As CommandButton With ;
Top = 492, ;
Left = 264, ;
Height = 36, ;
Width = 109, ;
FontSize = 14, ;
Caption = "Draw text", ;
ForeColor = Rgb(128,0,64), ;
BackColor = Rgb(128,255,0), ;
Name = "Command5"

Add Object command4 As CommandButton With ;
Top = 492, ;
Left = 372, ;
Height = 36, ;
Width = 84, ;
FontBold = .T., ;
FontSize = 14, ;
Caption = "yFox", ;
ForeColor = Rgb(255,0,0), ;
BackColor = Rgb(255,128,0), ;
Name = "Command4"

Add Object command6 As CommandButton With ;
Top = 492, ;
Left = 456, ;
Height = 36, ;
Width = 73, ;
FontBold = .T., ;
FontSize = 12, ;
Caption = "Circles", ;
ForeColor = Rgb(64,0,64), ;
backcolor=rgb(0,255,0),;
Name = "Command6"

Procedure yfloodfill
Lparameters nXcoord,nyCoord,tncolor

#Define FLOODFILLBORDER 0 && Fill until crColor& color encountered.
#Define FLOODFILLSURFACE 1 && Fill surface until crColor& color not encountered.


Local lnHDC, lhBrush

lnHDC=getWindowDC(Thisform.yhwnd)
* Create a solid brush
lhBrush = CreateSolidBrush(tncolor)

* Select the brush into the PictureBox' device context
xxx=SelectObject(lnHDC, lhBrush)

* Fill the object
*yyy=ExtFloodFill(lnHDC, lnPosX, lnPosY, GetPixel(lnHDC, lnPosX, lnPosY), FLOODFILLSURFACE)

yyy=ExtFloodFill(lnHDC, nXcoord, nyCoord,GetPixel(lnHDC, nXcoord, nyCoord) ,FLOODFILLSURFACE )
* Release the brush
zzz=DeleteObject(lhBrush)

Thisform.MousePointer=0
Endproc


Procedure ydraw
Thisform.ForeColor=Rgb(0,255,0)
Thisform.DrawWidth=10

Thisform.Box(This.image1.Left-10,This.image1.Top-10,This.image1.Left+This.image1.Width+10,This.image1.Top+This.image1.Height+10)
Endproc

Procedure ystring
*Native gdiplus vfp9

* FontStyle: face types and common styles
#Define GDIPLUS_FontStyle_Regular 0
#Define GDIPLUS_FontStyle_Bold 1
#Define GDIPLUS_FontStyle_Italic 2
#Define GDIPLUS_FontStyle_BoldItalic 3
#Define GDIPLUS_FontStyle_Underline 4
#Define GDIPLUS_FontStyle_Strikeout 8

#Define GDIPLUS_Unit_Point 3 && 1/72 inch.

* Applies to GpStringFormat::Alignment, GpStringFormat::LineAlignment
#Define GDIPLUS_STRINGALIGNMENT_Near 0 && in Left-To-Right locale, this is Left
#Define GDIPLUS_STRINGALIGNMENT_Center 1
#Define GDIPLUS_STRINGALIGNMENT_Far 2 && in Left-To-Right locale, this is Right


oBounds = Newobject( ;
'GpRectangle',Home(1)+'ffc/_gdiplus.vcx','' ;
, +320 ;
, +300 ;
, Thisform.Width/2;
, Thisform.Height/2 ;
)

oLineColor = Newobject( ;
'GpColor',Home(1)+'ffc/_gdiplus.vcx','', 0,0,100 )
Open = Newobject('GpPen', Home(1)+'ffc/_gdiplus.vcx' )
Open.Create( m.oLineColor, 3 )


oFont = Newobject('GpFont',Home(1)+'ffc/_gdiplus.vcx')
oFont.Create( "Arial" ; && font name
, 28 ; && size in units below
, GDIPLUS_FontStyle_BoldItalic ; && attributes
, GDIPLUS_Unit_Point ; && units
)

oStringFormat = Newobject( ;
'GpStringFormat',Home(1)+'ffc/_gdiplus.vcx')
oStringFormat.Create( )

oStringFormat.Alignment ;
= GDIPLUS_STRINGALIGNMENT_Near

* Create a bright green brush
Local oFillColor As GpColor Of Home(1)+"ffc/_gdiplus.vcx" ;
, oBrush As GpSolidBrush Of "home(1)+ffc/_gdiplus.vcx"
oFillColor = Newobject( ;
'GpColor',Home(1)+'ffc/_gdiplus.vcx','' ;
, 0,255,0 ) && green
oBrush = Newobject( ;
'GpSolidBrush', Home(1)+'ffc/_gdiplus.vcx', '' ;
, m.oFillColor )

Local ystr
ystr="Drawing on vfp top level form surface"
oBrush.BrushColor = 0xA8500000
Thisform.ogr.DrawStringA(m.ystr, oFont, oBounds, oStringFormat, oBrush )


Retu

*DrawStringW( cUnicodeString, oFont, oRect, [oStringFormat], [oBrush] ) &&UNICODE
*DrawStringA( cUnicodeString, oFont, oRect, [oStringFormat], [oBrush] ) &&standard
Endproc

Procedure MouseDown
Lparameters nButton, nShift, nXcoord, nyCoord

#Define FLOODFILLBORDER 0 && Fill until crColor& color encountered.
#Define FLOODFILLSURFACE 1 && Fill surface until crColor& color not encountered.

Local lpPoint, lnPosX, lnPosY
lpPoint = Space(8)
If GetCursorPos(@lpPoint) = 0
Return
Endif

lnPosX = Asc(Substr(lpPoint,1))*256^0+;
ASC(Substr(lpPoint,2))*256^1+;
ASC(Substr(lpPoint,3))*256^2+;
ASC(Substr(lpPoint,4))*256^3

lnPosY = Asc(Substr(lpPoint,5))*256^0+;
ASC(Substr(lpPoint,6))*256^1+;
ASC(Substr(lpPoint,7))*256^2+;
ASC(Substr(lpPoint,8))*256^3

Local lnNewColor, lnHDC, lhBrush

lnHDC=getWindowDC(Thisform.yhwnd)


* Create a solid brush
lhBrush = CreateSolidBrush(Thisform.ycolor)

* Select the brush into the PictureBox' device context
xxx=SelectObject(lnHDC, lhBrush)


* Fill the object
yyy=ExtFloodFill(lnHDC, nXcoord, nyCoord,GetPixel(lnHDC, nXcoord, nyCoord) , FLOODFILLSURFACE)
* Release the brush
zzz=DeleteObject(lhBrush)

Thisform.MousePointer=0
Retu
Endproc

Procedure Activate

Thisform.BackColor = Rgb(255,255,255)

Thisform.DrawWidth = 5
Thisform.ForeColor = Rgb(0,0,255)
Thisform.Box(5,5,Thisform.Width - 5, Thisform.Height - 5)

Thisform.ForeColor = 0
Thisform.Box(420,210,420+290,230+200)

Thisform.ForeColor = Rgb(255,0,64)
Thisform.Circle(100,530,320)

Thisform.ForeColor = Rgb(0,255,64)
Thisform.Circle(45,490,330)

Thisform.DrawWidth=2
Thisform.ForeColor=255

For i=0 To 360 Step 0.5
*80*cos(8x)
posx=400+i
posY=100+80*Cos(8*i*Pi()/180)
oposx=400+i-0.5
oposy=100+80*Cos(8*(i-0.5)*Pi()/180)
Thisform.Line( oposx,oposy,posx,posY)
Endfor
Thisform.ForeColor=Rgb(0,0,255)
For i=0 To 360 Step 0.5
*80*cos(8x)
posx=400+i
posY=100+80*Sin(8*i*Pi()/180)
oposx=400+i-0.5
oposy=100+80*Sin(8*(i-0.5)*Pi()/180)
Thisform.Line( oposx,oposy,posx,posY)
Endfor
Thisform.ForeColor=Rgb(0,255,0)
Thisform.DrawWidth=4
Thisform.Box(390,10,390+370,20+170)
Thisform.ydraw()
Endproc

Procedure Init
Publi yrep
yrep=Addbs(Justpath(Sys(1071,This)))
Set Defa To (yrep)
With This
.ShowTips=.T.
.SetAll("mousepointer",15,"commandbutton")

#Define GW_CHILD 5
Declare Integer GetWindow In user32;
INTEGER HWnd,;
INTEGER wFlag

If .ShowWindow= 2
.yhwnd = GetWindow(.HWnd, GW_CHILD)
Else
.yhwnd= Thisform.HWnd &&_vfp.hwnd
Endif

* Iif(.ShowWindow = 2, Sys(2327, Sys(2325, Sys(2326, .HWnd))), .HWnd)

.Caption=Thisform.Caption+" Form.ShowWindow="+Trans(Thisform.ShowWindow)


.AddObject('Gpgraphics1','_gdiplus.Gpgraphics')
If Type('ThisForm.Gpgraphics1') # 'O' Or Isnull(.Gpgraphics1)
Return .F.
Endif
.Gpgraphics1.Name = Proper(.Gpgraphics1.Name)
.Gpgraphics1.CreateFromHWND(.yhwnd)
.ogr=.Gpgraphics1
Endwith

local m.myvar
text to m.myvar noshow &&ypalette.jpg
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj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cs4HDUYORmoXNPZvaomNOMDzqqGNUYpzGmZraEdTgnHUeKcKYDTga76Rk4EgqvJ0qYGoZOa9CmwjDUqSd/wAapSjr+NXpO9U5BXZTkdtOJU2ncakUGjb83WpFFbOZ30hyA1MgNMUVKorJyPQpSFNNINPNNNclVnWpjCKbg0/FJivPqblqZOlWI6gWpkrmkjgnIsoTU4JxVVanBGOtYSic02KxNRMTSk0xqaick0NY00UpporSMTklEcKcDTBSiuumRykgNQvUlRtXXBhGOpXeqzgVafvUDiuiEjpgiqQM1IoFKQc9KcAfStHI6oCqBUqimKKkWs3I66bCm0+krCbN1IYRSYFPNJg1ySK5iValU1GKeKzaONyJVNShhioAafuOKzcTJscWFNJpCaaTQomMkBNJmkpM1aiZOI/NKDTKXNaxJ5B4NRt0p2aYa2TBRGNULCpjTCK0UjWKIcc04Cl2jNKBV85rEAKeKTFOFS5G0WFIRTsUlZyZpzDSKTFOxRisWPnP/9k=
endtext
thisform.image1.pictureVAl=strconv(m.myvar,14)

Endproc

Procedure Load
Do Locfile("system.app")
Declare Integer SelectObject In WIN32API Integer hdc, Integer hgdiobj
Declare Integer GetPixel In win32API Integer hdc, Integer nXPos, Integer nYPos
Declare SHORT GetCursorPos In win32api String @ lpPoint
Declare Integer GetWindowDC In Win32API Integer HWnd
Declare Integer CreateSolidBrush In WIN32API Long crColor
Declare Long DeleteObject In WIN32API Long hObject
Declare Integer GetDC In user32 Integer HWnd
Declare Long ExtFloodFill In gdi32 Long hdc, Long x, Long Y, Long crColor, Long wFillType
Declare Long SetPixel In gdi32 Long hdc, Long x, Long Y, Long crColor

Set Classlib To Home(1)+"ffc\_gdiplus" AddI
Endproc


Procedure Destroy
Clear Dlls
Clea Events
Endproc


Procedure MouseMove
Lparameters nButton, nShift, nXcoord, nyCoord
This.ylab.Caption="X="+Trans(nXcoord)+" Y="+Trans(nyCoord)
Endproc


*Procedure image1.Init
* This.Picture="ypalette.jpg"
*Endproc


Procedure image1.MouseDown
Lparameters nButton, nShift, nXcoord, nyCoord
Thisform.ycolor=Thisform.Point(nXcoord,nyCoord)
Local xcaption
m.RGBChr=Left(BinToC(Thisform.ycolor,'R'),3)
xcaption= Trans(Thisform.ycolor)+" RGB("+Trans(Asc(Substr(m.RGBChr,1,1)))+","+Trans(Asc(Substr(m.RGBChr,2,1)))+","+Trans(Asc(Substr(m.RGBChr,3,1)))+")"
Thisform.label1.Caption="Color selected= "+m.xcaption
Thisform.MouseIcon="fill.cur"
Thisform.MousePointer=99
Endproc

Procedure command1.Click
#Define FLOODFILLSURFACE 1
Thisform.Cls
With _Screen.System.drawing
Local LOGFX As xfcGraphics

LOGFX=.graphics.fromhwnd(Thisform.yhwnd)

Pen=.Pen.new(.Color.blue,4)
LOGFX.drawRectangle(Pen,340,40,390,240)

Pen=.Pen.new(.Color.cyan,4)
LOGFX.drawRectangle(Pen,330,30,410,260)


Pen=.Pen.new(.Color.red,4)
LOGFX.drawEllipse(Pen,345,45,370,120)

Pen=.Pen.new(.Color.green,4)
LOGFX.drawEllipse(Pen,345,75,370,130)

Pen=.Pen.new(.Color.maroon,4)
LOGFX.drawEllipse(Pen,340,40,370,190)

Endwith


Local tncolor
tncolor = Rgb(Int(Rand()*255),Int(Rand()*255),Int(Rand()*255)) &&random color
Thisform.ycolor=m.tncolor
Local xcaption
m.RGBChr=Left(BinToC(Thisform.ycolor,'R'),3)
xcaption= Trans(Thisform.ycolor)+" RGB("+Trans(Asc(Substr(m.RGBChr,1,1)))+","+Trans(Asc(Substr(m.RGBChr,2,1)))+","+Trans(Asc(Substr(m.RGBChr,3,1)))+")"
Thisform.label1.Caption="Color selected= "+m.xcaption

*choice a point starting of floodfill
nXcoord=521
nyCoord=131

=Thisform.yfloodfill( nXcoord,nyCoord,tncolor)
Thisform.ystring()
Endproc


Procedure command2.Click
Thisform.Cls
Thisform.ydraw()
Endproc


Procedure command3.Click
Thisform.Activate()
Endproc


Procedure command5.Click
*texte
Local ystring
TEXT to ystring noshow
This is a demo how to draw directly on
VFP top level form surface directly
(as the native drawing function does).
This can be used on native vfp9 gdiplus
or on GdiplusX. All is on the good
form hwnd to choice.
The drawing will be persistent if binding
the form with windows messages and APIs
BeginPaint,EndPaint.
ENDTEXT
Thisform.Cls
Thisform.BackColor=Rgb(255,255,255)
With _Screen.System.drawing
Local loFont As xfcFont
Local loBrush As xfcLinearGradientBrush
Local loRectangleF As xfcRectangleF
Local loSizeF As xfcSizeF
LOGFX=.graphics.fromhwnd(Thisform.yhwnd)
loFont = .Font.new("Arial Black", 14, .FontStyle.BoldItalic)
loSizeF = LOGFX.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.new(330,40,loSizeF.Width, loSizeF.Height)
loBrush = .Drawing2D.LinearGradientBrush.new(loRectangleF,.Color.red,.Color.green,3)
LOGFX.DrawString(ystring, loFont,loBrush, loRectangleF)

ystring="Yousfi Benameur February,2013"
loFont = .Font.new("tahoma", 9, .FontStyle.BoldItalic)
loSizeF = LOGFX.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.new(Thisform.Width-loSizeF.Width-50,Thisform.Height-loSizeF.Height-200,loSizeF.Width, loSizeF.Height)
loBrush = .Drawing2D.LinearGradientBrush.new(loRectangleF,.Color.red,.Color.green,3)
LOGFX.DrawString(ystring, loFont,loBrush, loRectangleF)
Endwith
Thisform.Refresh
Endproc

Procedure command4.Click
Local yhwnd
yhwnd=Thisform.yhwnd
Thisform.Cls
Local loPen As xfcPen
Local LOGFX As xfcGraphics

*this.clear()
With _Screen.System.drawing
LOGFX = .graphics.fromhwnd(m.yhwnd)
loState = LOGFX.Save()
lorectangle=.rectangle.new(0,0,Thisform.Width,Thisform.Height-Thisform.command1.Height-20)

LOGFX.drawImage(.Bitmap.new("Taghit.jpg"),lorectangle)   &&can put here getpict() instead of Taghit.jpg
* Draw signature
Local x0,y0
x0=This.Width*0.2
y0=This.Height-25
LOGFX.DrawString("Re Click menu to view other colors Yousfi Benameur "+Dtoc(Date()),.Font.new("Tahoma", 15), .Brushes.white, x0,y0)

*Applying filter with random colors
*if thisform.y=1
Local loPathz As xfcGraphicsPath
loPathz = .Drawing2D.GraphicsPath.new()
loRectz=.rectangle.new(1,1,1024,768)
loPathz.AddRectangle(loRectz)

Local loPathGradBrushz As xfcPathGradientBrush
loPathGradBrushz = .Drawing2D.PathGradientBrush.new(loPathz)
Rand(-1)
gnLower = 0
gnUpper = 16777000
xc= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)

loPathGradBrushz.CenterColor = .Color.fromRGB(120,xc)
Rand(-1)
gnLower = 0
gnUpper = 16777000
xc= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)

loPathGradBrushz.SurroundColors[1] = .Color.fromARGB(180,xc)

LOGFX.FillPath(loPathGradBrushz, loPathz)
*endi

x=255
loPen=.Pen.new(.Color.fromRGB(x),3)

Local loPath As xfcGraphicsPath
loPath = .Drawing2D.GraphicsPath.new()
loRect=.rectangle.new(1,1,270,270)
loPath.AddEllipse(loRect)

Local loPathGradBrush As xfcPathGradientBrush
loPathGradBrush = .Drawing2D.PathGradientBrush.new(loPath)
Rand(-1)
gnLower = 0
gnUpper = 16777000
xc= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)

loPathGradBrush.CenterColor = .Color.fromRGB(xc)
Rand(-1)
gnLower = 0
gnUpper = 16777000
xc= Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)

loPathGradBrush.SurroundColors[1] = .Color.fromARGB(80,xc)
LOGFX.FillPath(loPathGradBrush, loPath)

*draw fox with Bezier curves (this from BBout-gdiplusPad page)
*fox head BB
Local oCap As xfcCustomLineCap
loPen=.Pen.new(.Color.greenyellow,12)

Local otrans As xfcMatrix
oPath =.Drawing2D.GraphicsPath.new()
** Forehead
oPath.StartFigure()
oPath.AddBezier(101,65, 90,70, 90,70, 82,96)
** Left Cheek
oPath.StartFigure()
oPath.AddBezier(124,129, 130,140, 132,151, 132,151)
oPath.AddBezier(132,151, 100,160, 100,155, 77,161)
** Head and ears
oPath.StartFigure()
oPath.AddBezier(102,212, 170,160, 170,120, 166,89)
oPath.AddBezier(166,89, 180,60, 192,50, 191,2)
oPath.AddBezier(191,2, 150,20, 140,30, 120,51)
oPath.AddBezier(120,51, 100,45, 75,44, 69,46)
oPath.AddBezier(69,46, 50,14, 25,30, 6,2)
oPath.AddBezier(6,2, 0,30, 0,40, 14,81)
** Right cheek
oPath.StartFigure()
oPath.AddBezier(29,102, 16,118, 16,126, 28,146)
** Nose
oPath.StartFigure()
oPath.AddBezier(45,150, 38,160, 38,160, 23,169)
oPath.StartFigure()
oPath.AddBezier(38,190, 60,190, 70,175, 82,177)
oPath.StartFigure()
oPath.AddBezier(16,173, 22,171, 25,171, 30,173)
oPath.AddBezier(30,173, 32,182, 32,182, 23,189)
oPath.AddBezier(23,189, 14,183, 14,183, 16,173)
** Right eye
oPath.StartFigure()
oPath.AddBezier(36,114, 45,120, 50,120, 50,141)
oPath.AddBezier(47,135, 38,130, 38,130, 40,121)
oPath.CloseFigure()
** Left eye
oPath.StartFigure()
oPath.AddBezier(103,120, 90,125, 70,140, 65,148)
oPath.AddBezier(75,141, 85,140, 89,140, 92,130)
oPath.CloseFigure()
LOGFX.SmoothingMode = .Drawing2D.SmoothingMode.AntiAlias
LOGFX.translateTransform(30,30)
LOGFX.DrawPath(loPen, oPath)
loPen=.Pen.new(.Color.red,6)
LOGFX.DrawPath(loPen, oPath)
LOGFX.Restore(loState)
Endwith
Endproc

Procedure command6.Click
Thisform.Cls
With _Screen.System.drawing
Local LOGFX As xfcGraphics
LOGFX = .graphics.fromhwnd(Thisform.yhwnd)

Local loBMP As xfcBitmap
loBMP=.Bitmap.new(400,400)
yogfx= .graphics.FromImage(loBMP)
yogfx.Clear(.Color.white)
Local Pen As xfcPen
Pen=.Pen.new(.Color.fromARGB(200,.Color.cyan),4) && cyan with transparency
yogfx.drawEllipse(Pen,0,0,400,400)
loBMP.Save(Addbs(Sys(2023))+"mycircle.bmp",.imaging.imageformat.bmp)
Endwith
Pen.dispose()

Local lcSource, lnWidth, lnHeight
lcSource = Addbs(Sys(2023))+"mycircle.bmp"
If Empty(lcSource)
Return .F.
Endif

With _Screen.System.drawing
Local loBmp0,loBMP As xfcBitmap
loBmp0=.Bitmap.new(Thisform.Width-10,Thisform.Height-5)
LOGFX.Clear(.Color.black)
xc=Thisform.Width/2
yc=Thisform.Height/2

loBMP = .Bitmap.FromFile(m.lcSource)
loBMP.maketransparent(.Color.white)
w=loBMP.Width/2
h=loBMP.Height/2

oState = LOGFX.Save()
LOGFX.translateTransform(xc,yc)

For i=0 To 360 Step 3
LOGFX.RotateTransform(i)
LOGFX.drawImage(loBMP,0,-h/2,w,h)
Endfor
LOGFX.Restore(oState)

*texte
Local loFont As xfcFont
Local loBrush As xfcLinearGradientBrush
Local loRectangleF As xfcRectangleF
Local loSizeF As xfcSizeF

ystring="Yousfi Benameur - November 2008......clear after 5sec ..."

loFont = .Font.new("Arial Black", 14 ,.FontStyle.BoldItalic)
loSizeF = LOGFX.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.new(0+10,10,loSizeF.Width, loSizeF.Height)
loBrush = .Drawing2D.LinearGradientBrush.new(loRectangleF,.Color.red,.Color.green,0)
LOGFX.DrawString(ystring, loFont,loBrush, loRectangleF)

*loBmp0.Save("c:\mycircle_rotated.png", .Imaging.ImageFormat.Png)
Set Safe Off
Dele File (Addbs(Sys(2023))+"mycircle.bmp"
Set Safe On

Endwith
Inke(5)
Thisform.Cls
Thisform.Activate()
Retu
Endproc


Enddefine
*

*end code

 

the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.
the last photo (taghit.jpg) is a part of code.download it in same folder of code.

the last photo (taghit.jpg) is a part of code.download it in same folder of code.

*always in gdiplusX drawing register
*This code draw circles and fill with grandom colors gradients
*it uses Drawing2D.LinearGradientBrush function.

*the code ask you topoint to gdiplusX and system.app

*2*
*Begin code
Set Classlib To Locfile("gdiplusX.vcx","vcx") AddI  &&point to gdiplusX class
Publi yform
yform=Newobject("ygrad_circle")
Release Classlib gdiplusX
yform.Show
Read Events
Return

*
Define Class ygrad_circle As Form
    BorderStyle = 2
    Top = 96
    Left = 127
    Height = 272
    Width = 607
    ShowWindow = 2
    Picture = ""
    Caption = "Form1"
    MaxButton = .F.
    BackColor = Rgb(0,0,0)
    ymode = .F.
    ynumber = .F.
    AutoCenter=.T.
    Caption="GdiplusX drawings"
    Name = "Form1"

    Add Object imgcanvas1 As imgcanvas With ;
        Anchor = 15, ;
        Height = 200, ;
        Left = 0, ;
        Top = 0, ;
        Width = 200, ;
        rendermode = 0, ;
        Name = "Imgcanvas1"

    Add Object imgcanvas2 As imgcanvas With ;
        Anchor = 15, ;
        Height = 200, ;
        Left = 199, ;
        Top = 0, ;
        Width = 200, ;
        Name = "Imgcanvas2"

    Add Object command1 As CommandButton With ;
        Top = 240, ;
        Left = 228, ;
        Height = 25, ;
        Width = 109, ;
        backcolor=Rgb(0,255,0), ;
        Caption = "Re Draw", ;
        Name = "Command1"

    Add Object imgcanvas3 As imgcanvas With ;
        Anchor = 24, ;
        Height = 200, ;
        Left = 399, ;
        Top = -1, ;
        Width = 200, ;
        Name = "Imgcanvas3"

    Add Object command2 As CommandButton With ;
        Top = 240, ;
        Left = 372, ;
        Height = 25, ;
        Width = 49, ;
        Caption = "50 X", ;
        backcolor=255,;
        Name = "Command2"

    Add Object label1 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = "1", ;
        Height = 40, ;
        Left = 89, ;
        Top = 80, ;
        Width = 20, ;
        Name = "Label1"

    Add Object label2 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = "2", ;
        Height = 40, ;
        Left = 290, ;
        Top = 81, ;
        Width = 20, ;
        Name = "Label2"


    Add Object label3 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = "3", ;
        Height = 40, ;
        Left = 492, ;
        Top = 81, ;
        Width = 20, ;
        Name = "Label3"

    Procedure yupdate
        Thisform.ymode=Thisform.ymode+1
        If Thisform.ymode>3
            Thisform.ymode=0
        Endi
    Endproc

    Procedure Destroy
        Set Curs On
        Clea Events
    Endproc

    Procedure Init
        Set Curs Off
        This.ymode=0
        This.SetAll("forecolor",Rgb(255,255,255),"label")
    Endproc

    Procedure Load
        Declare Integer Sleep In kernel32 Integer

        Do Locfile("system.app")
    Endproc

    Procedure imgcanvas1.beforedraw
        Thisform.yupdate()
        Thisform.label1.Caption=Trans(Int(9*Rand()))

        With _Screen.System.Drawing
            This.Clear(.Color.black)
            logfx=This.ogfx
            Local color1,color2 As xfcColor
            color1=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())
            color2=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())

            dd=5
            lorect1=.rectangle.new(0+dd,0+dd,This.Width-2*dd,This.Height-2*dd)
            br = .Drawing2D.LinearGradientBrush.new(lorect1,color1,color2,Pi()*Thisform.ymode/2,.T.)
            logfx.fillEllipse(br,lorect1)
            Pen=.Pen.new(.Color.gold,6)
            logfx.drawEllipse(Pen,lorect1)

            br=.SolidBrush.new(.Color.fromRGB(Thisform.BackColor))
            u=This.Width/3
            lorect2=.rectangle.new(u,u,This.Width-2*u,This.Height-2*u)
            logfx.fillEllipse(br,lorect2)
            Pen=.Pen.new(.Color.gold,6)
            logfx.drawEllipse(Pen,lorect2)

        Endwith
        Retu
    Endproc

    Procedure imgcanvas2.beforedraw
        Thisform.yupdate()
        Thisform.label2.Caption=Trans(Int(9*Rand()))

        With _Screen.System.Drawing
            This.Clear()
            logfx=This.ogfx
            Local color1,color2 As xfcColor

            color1=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())
            color2=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())

            dd=5
            xpath = .Drawing2D.GraphicsPath.new()
            xpath.AddEllipse(0+dd,0+dd,This.Width-2*dd,This.Height-2*dd)
            u=This.Width/3
            xpath.AddEllipse(0+u,0+u,This.Width-2*u,This.Height-2*u)
            lorect1=.rectangle.new(0,0,This.Width,This.Height)
            Pen=.Pen.new(.Color.gold,6)
            logfx.DrawPath(Pen,xpath)
            br = .Drawing2D.LinearGradientBrush.new(lorect1,color1,color2,Pi()*Thisform.ymode/2,.T.)
            logfx.fillpath(br,xpath)
        Endwith
    Endproc

    Procedure command1.Click
        With Thisform
            .imgcanvas1.Draw
            .imgcanvas2.Draw
            .imgcanvas3.Draw
        Endwith
    Endproc

    Procedure imgcanvas3.beforedraw

        Thisform.yupdate()
        Thisform.label3.Caption=Trans(Int(9*Rand()))

        With _Screen.System.Drawing
            This.Clear()
            logfx=This.ogfx
            Local color1,color2 As xfcColor

            color1=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())
            color2=.Color.fromRGB(255*Rand(),255*Rand(),255*Rand())

            dd=5
            xpath = .Drawing2D.GraphicsPath.new()
            xpath.AddEllipse(0+dd,0+dd,This.Width-2*dd,This.Height-2*dd)
            u=This.Width/3
            xpath.AddEllipse(0+u,0+u,This.Width-2*u,This.Height-2*u)
            lorect1=.rectangle.new(0,0,This.Width,This.Height)
            Pen=.Pen.new(.Color.gold,6)
            logfx.DrawPath(Pen,xpath)
            br = .Drawing2D.LinearGradientBrush.new(lorect1,color1,color2,Pi()*Thisform.ymode/2,.T.)
            logfx.fillpath(br,xpath)
        Endwith

    Endproc

    Procedure command2.Click
        For i=1 To 50
            Thisform.command1.Click
            Sleep(50)
        Endfor
    Endproc


Enddefine
*

*End code

 

can redraw to others colors-click also to make an animation.
can redraw to others colors-click also to make an animation.

can redraw to others colors-click also to make an animation.

Click on code to select [then copy] -click outside to deselect


*5*
*run this code with vfp9.exe as administrator for IE11 purpose(as viewer). 
*added on Monday  14 march 2016; 17:03:22
*draw a circle, save to image and rotate to build another image as 5 images rotation result
*run vfp9.exe as administrator for IE11 purpose.

Set Safe Off
Do Locfile("System.App")
Publi m.yrep
m.yrep= Addbs(Sys(2023))

&&make a circle drawn with many colors,many arc portions  and save as image bmp (source)
With _Screen.System.drawing
    Local loBMP As xfcBitmap
	loBMP=.Bitmap.new(400,400)
	yogfx= .Graphics.FromImage(loBMP)

	For j=1 To 5
		yogfx.Clear(.Color.white)
		Do Case
		Case j=1
			Pen=.Pen.new(.Color.cyan,4)
			yogfx.drawellipse(Pen,0,0,400,400)
			
		Case j=2
			Pen=.Pen.new(.Color.lime,4)
			yogfx.drawArc(Pen,0,0,400,400,0,300)
			Pen=.Pen.new(.Color.gold,4)
			yogfx.drawArc(Pen,0, 0, 400, 400, 0, 180)
			Pen=.Pen.new(.Color.red,4)
			yogfx.drawArc(Pen,0, 0, 400, 400,91, 180)
				
				
		Case j=3
			Pen=.Pen.new(.Color.cyan,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400, 0, 360)
			Pen=.Pen.new(.Color.red,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,91, 180)

		Case j=4
			Pen=.Pen.new(.Color.cyan,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400, 0, 360)
			Pen=.Pen.new(.Color.red,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,91, 150)
			Pen=.Pen.new(.Color.green,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,150, 180)

		Case j=5
			Pen=.Pen.new(.Color.gold,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400, 0, 360)
			Pen=.Pen.new(.Color.lime,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,91, 110)
			Pen=.Pen.new(.Color.blue,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,110, 160)
			Pen=.Pen.new(.Color.tomato,4)
			yogfx.DrawArc(Pen,0, 0, 400, 400,150, 180)
		Endcase
		loBMP.Save(m.yrep+"mycircle"+Trans(j)+".bmp",.imaging.imageformat.bmp)
	Endfor
	Pen.dispose()
Endwith

Local lcSource, lnWidth, lnHeight
For j=1 To 5
	Do Case
	Case j=1
		lcSource =m.yrep+ "mycircle1.bmp"
	Case j=2
		lcSource =m.yrep+ "mycircle2.bmp"
	Case j=3
		lcSource =m.yrep+ "mycircle3.bmp"
	Case j=4
		lcSource =m.yrep+ "mycircle4.bmp"
	Case j=5
		lcSource =m.yrep+ "mycircle5.bmp"	
	Endcase

	If Empty(lcSource)
		Exit
	Endif

	With _Screen.System.drawing
		Local loBmp0,loBMP As xfcBitmap
		loBmp0=.Bitmap.new(_Screen.Width-10,_Screen.Height-5)
		logfx= .Graphics.FromImage(loBmp0)
		logfx.Clear(.Color.black)

		xc=_Screen.Width/2
		yc=_Screen.Height/2


		loBMP = .Bitmap.FromFile(lcSource)
		loBMP.maketransparent(.Color.white)
		w=loBMP.Width/2
		h=loBMP.Height/2


		oState = logfx.Save()
		logfx.TranslateTransform(xc,yc)
		For i=0 To 360 Step 3
			logfx.RotateTransform(i)
			logfx.DrawImage(loBMP,0,0,w,h)
		Endfor

		logfx.Restore(oState)

*texte
		Local loFont As xfcFont
		Local loBrush As xfcLinearGradientBrush
		Local loRectangleF As xfcRectangleF
		Local loSizeF As xfcSizeF

		ystring="Yousfi Benameur November 2008"

		loFont = .Font.new("Arial Black", 10 ,.FontStyle.BoldItalic)
		loSizeF = logfx.MeasureString(ystring, loFont)
		loRectangleF =_Screen.System.drawing.RectangleF.new(xc+loSizeF.Width/2,_Screen.Height-25,loSizeF.Width, loSizeF.Height)
		loBrush = .Drawing2D.LinearGradientBrush.new(loRectangleF,.Color.red,.Color.green,0)
		logfx.DrawString(ystring, loFont,loBrush, loRectangleF)

		loBmp0.Save(m.yrep+"mycircle_rotated"+Trans(j)+".png", .imaging.imageformat.Png)
		Dele File (lcSource)
	Endwith
Endfor

*view with IE
Local m.myvar
TEXT to m.myvar textmerge noshow
<body bgcolor=black oncontextmenu="return false;">
<input type="Button" value="X" style="float:right;background-color:lime; color:red;cursor:pointer;" onclick="window.open('','_self');window.close();">
<center><h2 style="color:gold;">5 Images rotations</h2></center>
<br>
<center>
<img src="<<m.yrep+'mycircle_rotated1.png'>> "
<br>
<img src="<<m.yrep+'mycircle_rotated2.png'>> "
<br>
<img src="<<m.yrep+'mycircle_rotated3.png'>> "
<br>
<img src="<<m.yrep+'mycircle_rotated4.png'>> "
<br>
<img src="<<m.yrep+'mycircle_rotated5.png'>> "
</center>
</body<
ENDTEXT
lcdest=Addbs(Sys(2023))+"ytemp.html"
Strtofile(m.myvar,m.lcdest)

Set Safe On
Declare Integer BringWindowToTop In user32 Integer
Local  apie
apie=Newobject("internetexplorer.application")
With apie
	.Navigate(m.lcdest)
	.fullscreen=1
	BringWindowToTop(.HWnd)
	.Visible=.T.
Endwith

Retu



Drawing on top level form with gdiplusX and native vfp
Drawing on top level form with gdiplusX and native vfp
Drawing on top level form with gdiplusX and native vfp
Drawing on top level form with gdiplusX and native vfp

Click on code to select [then copy] -click outside to deselect


*6*
*draw rectangle, save th oGFx , rotate and restore to build multi rectangles glowed to image as result.
**added on Monday  14 march 2016; 17:23:42

Set Safe Off
Do Locfile("System.App")
Publi m.yrep
m.yrep= Addbs(Sys(2023))

With _Screen.System.drawing
    Local loBMP As xfcBitmap
	loBMP=.Bitmap.new(700,600)
	yogfx= .Graphics.FromImage(loBMP)
	yogfx.SmoothingMode = .Drawing2D.SmoothingMode.AntiAlias
	w=0
	xc=300
	yc=300
	yogfx.TranslateTransform(xc,yc)
	yogfx.Clear(.Color.black)

	For j=1 To 360
		If Mod(j,2)=0
			Pen=.Pen.new(.Color.fromrgb(255*Rand(),255*Rand(),255*Rand()),1)
		Else
			Pen=.Pen.new(.Color.white,1)
		Endi

		w=w+5
		If w>700/2 +80
			Exit
		Endi

		xc=xc-w/2
		yc=yc-w/2
		ostate = yogfx.Save()
		yogfx.RotateTransform(j*180/Pi())
		yogfx.drawRectangle(Pen,-w/2,-w/2,w,w)
		yogfx.Restore(ostate)

	Endfor

*texte
		Local loFont As xfcFont
		Local loBrush As xfcLinearGradientBrush
		Local loRectangleF As xfcRectangleF
		Local loSizeF As xfcSizeF

		ystring="Yousfi Benameur November 2008"

		loFont = .Font.new("Arial Black", 10 ,.FontStyle.BoldItalic)
		loSizeF = yogfx.MeasureString(ystring, loFont)
        loRectangleF =.RectangleF.new(70,300-25,loSizeF.Width, loSizeF.Height)
		loBrush = .Drawing2D.LinearGradientBrush.new(loRectangleF,.Color.red,.Color.green,0)
		yogfx.DrawString(ystring, loFont,loBrush, loRectangleF)

	m.lcdest=m.yrep+"myrectangles.png"
	loBMP.Save(m.lcdest,.imaging.imageformat.png)
	Pen.dispose()
Endwith

Run/N explorer &lcdest
Retu


Drawing on top level form with gdiplusX and native vfp
To be informed of the latest articles, subscribe:
Comment on this post
H
thanks
Reply