Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

how to Anti Alias


  • Please log in to reply
2 replies to this topic

#1 PhoenixXL

PhoenixXL

    be what you are, its always the BEST..

  • MVPs
  • 1,561 posts

Posted 15 June 2012 - 07:23 AM

Here is a code
AutoIt         
#include <GUIConstantsEx.au3> #include <GDIPlus.au3> _Main() Func _Main() Local $hGUI, $hGraphic ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) GUISetState() _Curvature($hGUI,160,100,20,20,100,180,0x702E2EFE) _DrawLine($hGui,160,100+(20/2),160,120+40,0x702E2EFE) _Curvature($hGUI,160,160-(20/2),20,20,-100,180,0x702E2EFE) ; Draw arcs ;_GDIPlus_GraphicsDrawArc($hGraphic, 180, 100, 10, 10, 180, 360) ;_GDIPlus_GraphicsDrawArc($hGraphic, 160, 104, 30, 30, 160, -140) ;_GDIPlus_GraphicsDrawArc($hGraphic, 140, 80, 70, 70, 180, 360) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources EndFunc   ;==>_Main Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel=0x80FFD700) Local  $hGraphic, $hPen ; Draw line _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Gui) $hPen = _GDIPlus_PenCreate ($sChannel) If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error from GDI+:'&@error&@CRLF) ; Clean up resources _GDIPlus_PenDispose ($hPen) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_ShutDown () ;Done..... EndFunc   ;==>_Main Func _Curvature($hGui, $iX, $iY, $iWidth, $iHeight, $fSweepAngle,$fStartAngle=180, $hPen = 0x80FFD700) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $hPen=_GDIPlus_PenCreate($hPen) _GDIPlus_GraphicsDrawArc($hGraphic, $iX, $iY, $iWidth, $iHeight, $fStartAngle, $fSweepAngle , $hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc


I want to anti alias the Curves
I have already seen _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $iSmooth)
But it doesnt seem to do anything

Please guide me in the right direction

Thnx for your Time ;)

Edited by PhoenixXL, 15 June 2012 - 07:25 AM.

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. |

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. |

MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. |

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. |








#2 UEZ

UEZ

    Never say never

  • MVPs
  • 5,041 posts

Posted 15 June 2012 - 07:52 AM

Try this:

AutoIt         
#include <guiconstantsex.au3> #include <gdiplus.au3> _GDIPlus_Startup() Global $hGraphic, $hGUI _Main() Func _Main()     ; Create GUI     $hGUI = GUICreate("GDI+", 400, 300)     GUISetState()     $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)     _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)     _Curvature($hGUI,160,100,20,20,100,180,0x702E2EFE)     _DrawLine($hGui,160,100+(20/2),160,120+40,0x702E2EFE)     _Curvature($hGUI,160,160-(20/2),20,20,-100,180,0x702E2EFE)     ; Draw arcs     ;_GDIPlus_GraphicsDrawArc($hGraphic, 180, 100, 10, 10, 180, 360)     ;_GDIPlus_GraphicsDrawArc($hGraphic, 160, 104, 30, 30, 160, -140)     ;_GDIPlus_GraphicsDrawArc($hGraphic, 140, 80, 70, 70, 180, 360)     ; Loop until user exits     Do     Until GUIGetMsg() = $GUI_EVENT_CLOSE     ; Clean up resources     _GDIPlus_GraphicsDispose ($hGraphic)     _GDIPlus_ShutDown ()     Exit EndFunc   ;==>_Main Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel=0x80FFD700)     Local $hPen = _GDIPlus_PenCreate ($sChannel)     If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error from GDI+:'&@error&@CRLF)     _GDIPlus_PenDispose ($hPen) EndFunc Func _Curvature($hGui, $iX, $iY, $iWidth, $iHeight, $fSweepAngle,$fStartAngle=180, $hPen = 0x80FFD700)     $hPen=_GDIPlus_PenCreate($hPen)     _GDIPlus_GraphicsDrawArc($hGraphic, $iX, $iY, $iWidth, $iHeight, $fStartAngle, $fSweepAngle , $hPen)     _GDIPlus_PenDispose ($hPen) EndFunc


Btw, you don't need to start/shutdown GDI+ in each function. Create a global graphic handle and use it in you functions.


Or use this:
AutoIt         
;coded by UEZ 2012 #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() $iW = 640 $iH = 480 $hgui = GUICreate("GDI+ draw rectangle with round corners", $iW, $iH) GUISetBkColor(0x000020, $hgui) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) $p = 150 Draw_RoundRect($hGraphic, $p, $p, $iW - $p, $p, $iH - 2 * $p) ;draw rectangle with round corners GUISetOnEvent(-3, "_Exit") While Sleep(100000) WEnd Func Draw_RoundRect($hGfx, $iX1, $iY1, $iX2, $iY2, $iDist, $iArcSize = 40, $iColor = 0xFFFFFFFF, $iPenSize = 2) ;coded by UEZ 2012     Local $hPen = _GDIPlus_PenCreate($iColor, $iPenSize)     _GDIPlus_GraphicsDrawLine($hGfx, $iX1, $iY1, $iX2 + 1, $iY2, $hPen) ;upper horizontal line     _GDIPlus_GraphicsDrawArc($hGfx, $iX1 - $iArcSize / 2, $iY1, $iArcSize + 1, $iArcSize + 1, -90, -90, $hPen) ;left upper corner     _GDIPlus_GraphicsDrawArc($hGfx, $iX2 - $iArcSize / 2, $iY2, $iArcSize, $iArcSize, 0, -90, $hPen) ;right upper corner     _GDIPlus_GraphicsDrawArc($hGfx, $iX1 - $iArcSize / 2, $iY2 + $iDist - $iArcSize, $iArcSize, $iArcSize, 180, -90, $hPen) ;left bottom corner     _GDIPlus_GraphicsDrawArc($hGfx, $iX2 - $iArcSize / 2, $iY2 + $iDist - $iArcSize, $iArcSize, $iArcSize, -270, -90, $hPen) ;right bottom corner     _GDIPlus_GraphicsDrawLine($hGfx, $iX1 - $iArcSize / 2, $iY1 + $iArcSize / 2 - 1, $iX1 - $iArcSize / 2, $iY1 + $iDist - $iArcSize / 2 + 1, $hPen) ;left vertical line     _GDIPlus_GraphicsDrawLine($hGfx, $iX2 + $iArcSize / 2, $iY2 + $iArcSize / 2 - 1, $iX2 + $iArcSize / 2, $iY2 + $iDist - $iArcSize / 2 + 1, $hPen) ;right vertical line     _GDIPlus_GraphicsDrawLine($hGfx, $iX1 - 1, $iY1 + $iDist, $iX2 + 1, $iY2 + $iDist, $hPen) ;lower horizontal line     _GDIPlus_PenDispose($hPen) EndFunc Func _Exit()     GUIDelete()     _GDIPlus_GraphicsDispose($hGraphic)     _GDIPlus_Shutdown()     Exit EndFunc


Br,
UEZ

Edited by UEZ, 15 June 2012 - 08:34 AM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#3 PhoenixXL

PhoenixXL

    be what you are, its always the BEST..

  • MVPs
  • 1,561 posts

Posted 15 June 2012 - 12:02 PM

Thnx UEZ it worked ;)

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. |

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. |

MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. |

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. |





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users