CodeTinkerer Posted May 6, 2015 Share Posted May 6, 2015 (edited) How would I go about getting a Transparent background for this _GDIPlus_GraphicsDrawStringEx ?, Ive already tried multiple UDF's that would work properly with the standard controls. expandcollapse popup#include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hwnd = GUICreate("GDI+ Example", 400, 300) $label = GUICtrlCreateLabel("", 10, 10, 380, 40) GUICtrlCreateButton("Start/Stop scrolling",150,50,100,30) GUICtrlSetOnEvent(-1,"startstop") GUISetOnEvent(-3, "close") GUICtrlCreatePic(@ScriptDir & '\Img\Main2.jpg' ,0 ,0 ,0 ,0 ,0 ,0 ) GUISetState() _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label)) $bitmap = _GDIPlus_BitmapCreateFromGraphics(380, 40, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $ffamily = _GDIPlus_FontFamilyCreate("Arial") $arial = _GDIPlus_FontCreate($ffamily, 24) $sformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($sformat, 1) $blackbrush = _GDIPlus_BrushCreateSolid() $pos = 0 $speed=0 Do _GDIPlus_GraphicsClear($backbuffer, 0xFFF0F0F0) $pos -= $speed $rectf = _GDIPlus_RectFCreate($pos, 0, 380, 40) If $pos < -300 Then $pos = 300 _GDIPlus_GraphicsDrawStringEx($backbuffer, "Scrolling text", $arial, $rectf, $sformat, $blackbrush) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 380, 40) Sleep(10) Until False Func startstop() $speed=Not $speed EndFunc Func close() _GDIPlus_BrushDispose($blackbrush) _GDIPlus_StringFormatDispose($sformat) _GDIPlus_FontDispose($arial) _GDIPlus_FontFamilyDispose($ffamily) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Edited May 6, 2015 by CodeTinkerer Link to comment Share on other sites More sharing options...
UEZ Posted May 7, 2015 Share Posted May 7, 2015 Instead of creating a background pic control create a bitmap with that image and copy it everytime to $backbuffer instead of using _GDIPlus_GraphicsClear($backbuffer, 0xFFF0F0F0).Otherwise it is directly not possible to move a transparent image over another. CodeTinkerer 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
CodeTinkerer Posted May 11, 2015 Author Share Posted May 11, 2015 Thank you UEZ. So Using _GDIPlus_BitmapCreateFromFile, How would I as you had said "copy" it to the $backbuffer? looking through the help I couldnt find a "copy" func per say Link to comment Share on other sites More sharing options...
UEZ Posted May 11, 2015 Share Posted May 11, 2015 Then try this:expandcollapse popup#include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hwnd = GUICreate("GDI+ Example", 400, 300) $label = GUICtrlCreateLabel("", 10, 10, 380, 40) GUICtrlCreateButton("Start/Stop scrolling",150,50,100,30) GUICtrlSetOnEvent(-1,"startstop") GUISetOnEvent(-3, "close") ;~ GUICtrlCreatePic(@ScriptDir & '\Test.jpg' , 0, 0, 400, 300) GUISetState() _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label)) $bitmap = _GDIPlus_BitmapCreateFromGraphics(380, 40, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $background = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\Test.jpg') $ffamily = _GDIPlus_FontFamilyCreate("Arial") $arial = _GDIPlus_FontCreate($ffamily, 24) $sformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($sformat, 1) $blackbrush = _GDIPlus_BrushCreateSolid() $pos = 0 $speed=0 Do _GDIPlus_GraphicsDrawImageRect($backbuffer, $background, 0, 0, 400, 300) $pos -= $speed $rectf = _GDIPlus_RectFCreate($pos, 0, 380, 40) If $pos < -300 Then $pos = 300 _GDIPlus_GraphicsDrawStringEx($backbuffer, "Scrolling text", $arial, $rectf, $sformat, $blackbrush) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 380, 40) Sleep(10) Until False Func startstop() $speed=Not $speed EndFunc Func close() _GDIPlus_BrushDispose($blackbrush) _GDIPlus_StringFormatDispose($sformat) _GDIPlus_FontDispose($arial) _GDIPlus_FontFamilyDispose($ffamily) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_BitmapDispose($background) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
qwert Posted May 12, 2015 Share Posted May 12, 2015 This method is nice to know of.I added a GraphicsClear statement to keep the text from smearing into black on black.But is that the proper solution? It seems to add a slight hesitation. Link to comment Share on other sites More sharing options...
UEZ Posted May 12, 2015 Share Posted May 12, 2015 _GDIPlus_GraphicsClear() erases the graphic context with the color you provide or by default with 0xFF000000 (black). So for moving objects you have to clear the graphic context otherwise smearing will appear.For alpha tranparency it might be a little bit more complicated depending on what you want to achieve. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
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