monoceres Posted December 5, 2008 Posted December 5, 2008 I made this example some time ago (shadow): expandcollapse popup;; Author: monoceres #include <GDIPlus.au3> #include <GUIConstantsEx.au3> $hWnd = GUICreate("GDI+ Example", 800, 150) GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) _GDIPlus_GraphicsClear($hGraphics) _AntiAlias($hGraphics,4) $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900) $hBrush2= _GDIPlus_BrushCreateSolid(0xFF002000) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 90) $hLayout = _GDIPlus_RectFCreate(0, 0, 800, 300) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush) For $i=0 To 10 DllStructSetData($hLayout,"Y",$i) DllStructSetData($hLayout,"X",$i) _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush2) Next DllStructSetData($hLayout,"Y",0) DllStructSetData($hLayout,"X",0) _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Func _GDIPlus_StringFormatSetAlign($hStringFormat,$iFlag) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetStringFormatAlign", "ptr", $hStringFormat,"short",$iFlag) If @error Then Return SetError(@error, @extended, 0) If $aResult[0]=0 Then Return SetError(0,0,1) Return SetError(1,0,0) EndFunc Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias Broken link? PM me and I'll send you the file!
torels Posted December 5, 2008 Posted December 5, 2008 A stupid suggestion... What about an IE embedded control with a css style applied to some text ? Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
Josbe Posted December 5, 2008 Posted December 5, 2008 Glow effect, not easy, but I think it's possible through GDI+.In the forum I never saw an example with the glow effect, maybe converting this code to AutoIt. I would like convert it, looks good the result, but I can't just now. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
scon Posted December 5, 2008 Author Posted December 5, 2008 (edited) TNX! So, i much it is necessary that text glowed, but I did not work with this module >Josbe I already was there, but my knowledges do not allow to use this code to do program in Autoit (( >torels IE embeded... I tried, but antiviral program bad understand such ( Edited December 5, 2008 by scon
Valuater Posted December 5, 2008 Posted December 5, 2008 I thought this is pretty awesome...http://www.autoitscript.com/forum/index.ph...st&p=611056might be a great starter, it might be what really you want also8)
scon Posted December 5, 2008 Author Posted December 5, 2008 >Valuater I need beautiful text with effect of the phosphorescence. I do not know what get this effect from module GDI+
Malkey Posted December 7, 2008 Posted December 7, 2008 In monoceres example, change _GDIPlus_GraphicsClear($hGraphics) to _GDIPlus_GraphicsClear($hGraphics,0xFFFFFFFF) This will change the background to white instead of the default colour for _GDIPlus_GraphicsClear(), which is black. The shadow of the text can be seen. This is a modified monoceres example, with a increasing transparency shadow, or a shadow with reducing opaqueness. And this example uses a gradient line brush to colour the text. expandcollapse popup;; A modified monoceres example #include <GDIPlus.au3> #include <GUIConstantsEx.au3> $hWnd = GUICreate("GDI+ Example", 800, 150) GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) _GDIPlus_GraphicsClear($hGraphics,0xffffffE0) _AntiAlias($hGraphics,4) $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900) $hBrush2= _GDIPlus_BrushCreateSolid(0xFF002000) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 90) $hLayout = _GDIPlus_RectFCreate(0, 0, 800, 300) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush) For $i=0 To 10 $hBrush2= _GDIPlus_BrushCreateSolid("0x" & Hex(255-(($i^2)*2.5) ,2) & "306030") DllStructSetData($hLayout,"Y",$i) DllStructSetData($hLayout,"X",$i) _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush2) Next DllStructSetData($hLayout,"Y",0) DllStructSetData($hLayout,"X",0) ;$hBrush2= _GDIPlus_BrushCreateSolid(0xFF00ff00) ; $hBrushLin = GDIPlus_CreateLineBrush(0, 0, 800, 300, 0xFF0000ff, 0xFFFFFFFF, 0) ;Blue to White _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrushLin) ; Gamma correction is enabled for this linear gradient brush. GDIPlus_SetLineGammaCorrection($hBrushLin, True) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Func _GDIPlus_StringFormatSetAlign($hStringFormat,$iFlag) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetStringFormatAlign", "ptr", $hStringFormat,"short",$iFlag) If @error Then Return SetError(@error, @extended, 0) If $aResult[0]=0 Then Return SetError(0,0,1) Return SetError(1,0,0) EndFunc Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias Func GDIPlus_CreateLineBrush($iPoint1X, $iPoint1Y, $iPoint2X, $iPoint2Y, $iArgb1 = 0xFF0000FF, _ $iArgb2 = 0xFFFF0000, $WrapMode = 0) Local $tPoint1, $pPoint1, $tPoint2, $pPoint2, $aRet, $res $tPoint1 = DllStructCreate("float X;float Y") $pPoint1 = DllStructGetPtr($tPoint1) DllStructSetData($tPoint1, "X", $iPoint1X) DllStructSetData($tPoint1, "Y", $iPoint1Y) $tPoint2 = DllStructCreate("float X;float Y") $pPoint2 = DllStructGetPtr($tPoint2) DllStructSetData($tPoint2, "X", $iPoint2X) DllStructSetData($tPoint2, "Y", $iPoint2Y) ;Note: Within _GDIPlus_Startup(), $ghGDIPDll is defined $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrush", "ptr", $pPoint1, "ptr", $pPoint2, "int", $iArgb1, _ "int", $iArgb2, "int", $WrapMode, "int*", 0) ;$res = "GdipCreateLineBrush " & @CRLF ;for $x = 0 to 6 ;$res &= $x & " " & $aRet[$x] & @CRLF ;Next ;ConsoleWrite($res & @CRLF) Return $aRet[6] EndFunc ;==>GDIPlus_CreateLineBrush Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection) Return $aResult[0] EndFunc ;==>GDIPlus_SetLineGammaCorrection
Malkey Posted December 7, 2008 Posted December 7, 2008 This is a glow example. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> Global $nPI = 3.1415926535897932384626433832795 $hWnd = GUICreate("GDI+ Example", 800, 150) $iGlow = 2 ; <== Amount of Glow min = 1 Max about 5 _GDIPlus_Startup() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(800, 150, $hGraphicGUI) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) _GDIPlus_GraphicsClear($hGraphics, 0xff003000) ; Black-green background ;_GDIPlus_GraphicsClear($hGraphics, 0xffffffff) ; White Background _AntiAlias($hGraphics, 4) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 90) $hLayout = _GDIPlus_RectFCreate(0, 0, 800, 150) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) For $i = 1 To 15 Step 3 $hBrush3 = _GDIPlus_BrushCreateSolid("0x" & hex($iGlow,2) & "00ff00"); <====== Glow (Transparency) For $x = 0 To 360 Step 6 DllStructSetData($hLayout, "Y", ((18 - $i)) * Sin($x * $nPI / 180)) DllStructSetData($hLayout, "X", ((18 - $i)) * Cos($x * $nPI / 180)) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) Next Next DllStructSetData($hLayout, "Y", 0) DllStructSetData($hLayout, "X", 0) $hStringFormat = _GDIPlus_StringFormatCreate() $hBrush3 = _GDIPlus_BrushCreateSolid("0xfF00FF00") _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) GUISetState() GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush3) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_Shutdown() Func _GDIPlus_StringFormatSetAlign($hStringFormat, $iFlag) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetStringFormatAlign", "ptr", $hStringFormat, "short", $iFlag) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] = 0 Then Return SetError(0, 0, 1) Return SetError(1, 0, 0) EndFunc ;==>_GDIPlus_StringFormatSetAlign Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hWnd, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT
martin Posted December 7, 2008 Posted December 7, 2008 Mmmm.. Nice examples Malkey. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
monoceres Posted December 7, 2008 Posted December 7, 2008 Yeah, really good examples. As usual from you I really would like to see a full-blown GDI+ app from you. Would rock my world Broken link? PM me and I'll send you the file!
Josbe Posted December 7, 2008 Posted December 7, 2008 @Malkey: Nice and simplified(code) glow effect! You are a GDI+ Teacher AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
wraithdu Posted December 8, 2008 Posted December 8, 2008 (edited) Nice example. I get a weird result on Vista though, if the font size drops below 67 (weird arbitrary number). Try the above example with these changes - Line 14 -> _GDIPlus_GraphicsClear($hGraphics, 0x00000000) ; transparent background Line 19 -> $hFont = _GDIPlus_FontCreate($hFamily, 40) ; font size 40 Why is there a black border around the text now? As soon as the font size reaches 67+, the black border goes away, and it's transparent like it should be. Ideas? Edited December 8, 2008 by wraithdu
Malkey Posted December 9, 2008 Posted December 9, 2008 Nice example. I get a weird result on Vista though, if the font size drops below 67 (weird arbitrary number). Try the above example with these changes -Line 14 -> _GDIPlus_GraphicsClear($hGraphics, 0x00000000) ; transparent backgroundLine 19 -> $hFont = _GDIPlus_FontCreate($hFamily, 40) ; font size 40Why is there a black border around the text now? As soon as the font size reaches 67+, the black border goes away, and it's transparent like it should be. Ideas?No ideas here. I can not reproduce your black border around the text on XP.
youknowwho4eva Posted December 9, 2008 Posted December 9, 2008 Tested on my XP SP3 no black border either. Giggity
youknowwho4eva Posted December 9, 2008 Posted December 9, 2008 Find me a Vista solution, then I'll be shocked Giggity
wraithdu Posted December 9, 2008 Posted December 9, 2008 (edited) Just so you know what I mean, here's what I'm talking about. This happens when there's transparency in the GraphicsClear function and the font is <= 66. _GDIPlus_GraphicsClear($hGraphics, 0x50FFFFFF) Edited December 9, 2008 by wraithdu
monoceres Posted December 9, 2008 Posted December 9, 2008 I can't reproduce on Vista... Broken link? PM me and I'll send you the file!
wraithdu Posted December 9, 2008 Posted December 9, 2008 (edited) I wish I could explain it then. I mean, the proof is in the screenshot. Video card issue maybe? It's a laptop w/ Nvidia GeForce Go 7400. HP hasn't updated their drivers in forever, so who knows. But I'm inclined to think otherwise. Just to be sure, you tried with a smaller font size, like 40 or whatever? Could you post a screenshot? EDIT - I get the same result in an XP virtual machine (VirtualBox) with this code. I removed the StringFormatSetAlign() function since it's now included in the .12 beta. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> Global $nPI = 3.1415926535897932384626433832795 $hWnd = GUICreate("GDI+ Example", 800, 150) $iGlow = 2 ; <== Amount of Glow min = 1 Max about 5 _GDIPlus_Startup() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(800, 150, $hGraphicGUI) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) _GDIPlus_GraphicsClear($hGraphics, 0x00003000) ; Black-green background ;_GDIPlus_GraphicsClear($hGraphics, 0xffffffff) ; White Background _AntiAlias($hGraphics, 4) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 50) $hLayout = _GDIPlus_RectFCreate(0, 0, 800, 150) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) For $i = 1 To 15 Step 3 $hBrush3 = _GDIPlus_BrushCreateSolid("0x" & hex($iGlow,2) & "00ff00"); <====== Glow (Transparency) For $x = 0 To 360 Step 6 DllStructSetData($hLayout, "Y", ((5 - $i)) * Sin($x * $nPI / 180)) DllStructSetData($hLayout, "X", ((5 - $i)) * Cos($x * $nPI / 180)) ;~ $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) Next Next DllStructSetData($hLayout, "Y", 0) DllStructSetData($hLayout, "X", 0) ;~ $hStringFormat = _GDIPlus_StringFormatCreate() $hBrush3 = _GDIPlus_BrushCreateSolid("0xfF00FF00") _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) GUISetState() GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush3) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_Shutdown() Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hWnd, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Edited December 9, 2008 by wraithdu
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now