Jump to content

Recommended Posts

Posted

So i want to make a very simple Raycaster with GDI+

The problem is that GDI+ is very slow and you see the picture building up itself. My pc is new and it shouldnt be its fault.

Is it possible to optimise this and make a fluant row of pictures?

Posted

So i want to make a very simple Raycaster with GDI+

The problem is that GDI+ is very slow and you see the picture building up itself. My pc is new and it shouldnt be its fault.

Is it possible to optimise this and make a fluant row of pictures?

Post some code to start with then maybe someone may be able to say if it can be optimized.

GDI+ can be reasonably fast , but in the same breath it really depends on the task at hand and how it's implemented.

Posted (edited)

I have no real code till now i just tested how fast GDI+ is.

But i think. If the user holds down the forward key the picture must reload without a break and this would look a bit like this:

theres no white then black then white.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
GUICreate("GDI+ Raycaster", 400, 300)
$Handle = WinGetHandle("GDI+ Raycaster")
GUISetState()

_GDIPlus_Startup ()
$Graphic = _GDIPlus_GraphicsCreateFromHWND ($Handle)
$Pen1 = _GDIPlus_PenCreate(0xFFFFFFFF,1,2)
$Pen2 = _GDIPlus_PenCreate(0xFF000000,1,2)

Do
For $i = 0 To 320
    _GDIPlus_GraphicsDrawLine ($Graphic,$i,0,$i,100,$Pen1)
Next
For $i = 0 To 320
    _GDIPlus_GraphicsDrawLine ($Graphic,$i,0,$i,100,$Pen2)
Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE

I think what i need is a buffer. But does one exist for GDI?

Edited by Arterie
Posted

I think what i need is a buffer. But does one exist for GDI?

There's no backbuffering functions in GDI+, however it's easy to make your own with the standard functions.

Here's an example. I do this for all my GDI work. No flickering :)

#include <GDIPlus.au3>
#include <misc.au3>
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate("GDI+ Sample!", 400, 400)
GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(400, 400, $graphics);  This is actually the buffer
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer
$white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)


$x = 175
$y = 175

Do
    
    #Region Animation Logic
    If _IsPressed("25") Then; Left arrow
        $x -= 5
    EndIf
    
    If _IsPressed("26") Then; up arrow
        $y -= 5
    EndIf
    
    If _IsPressed("27") Then; right arrow
        $x += 5
    EndIf
    
    If _IsPressed("28") Then; down arrow
        $y += 5
    EndIf
    #EndRegion Animation Logic
    

    
    _GDIPlus_GraphicsClear($backbuffer); Always start with a clean buffer!
    
    _GDIPlus_GraphicsFillEllipse($backbuffer, $x, $y, 50, 50, $white)
    
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 400, 400); Present buffer to screen!
    Sleep(15)
Until False

Func close()
    _GDIPlus_BrushDispose($white)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>close

Broken link? PM me and I'll send you the file!

  • 8 months later...
Posted

Hey Anyone ever try using this kind of backbuffer with some transparencies? Kind of trippy effect/problem...

_GDIPlus_GraphicsClear($backbuffer,0x05000000); Always start with a clean buffer!

I use Transparencies in my GDI App and I also want to use a backbuffer. Any thoughts on how to get rid of the Ghosting?

I've tried this...

_WinAPI_RedrawWindow($hwnd, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))

Doesn't help.

Thanks

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

Hey Anyone ever try using this kind of backbuffer with some transparencies? Kind of trippy effect/problem...

_GDIPlus_GraphicsClear($backbuffer,0x05000000); Always start with a clean buffer!

I use Transparencies in my GDI App and I also want to use a backbuffer. Any thoughts on how to get rid of the Ghosting?

I've tried this...

_WinAPI_RedrawWindow($hwnd, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))

Doesn't help.

Thanks

Can you post your code?

Try _GDIPlus_GraphicsClear($backbuffer,0xFF000000) and give your objects the tranparancies.

UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

The example in this thread is perfect as far as the code I need. I need my background to be transparent and I also use the $WS_EX_TRANSPARENT EX_STYLE so that the window is "Not Clickable" and you can see and work with windows that are behind it. The example in this thread is a perfect testing ground though, because what I want is basically to move the dot around, with a transparent background, and have it not ghost. This works perfectly if you do not use the backbuffering technique, and just draw directly on the $hGraphic, but there is some flickering, especially with older PC's.

Maybe this is not possible using this technique?

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

The example in this thread is perfect as far as the code I need. I need my background to be transparent and I also use the $WS_EX_TRANSPARENT EX_STYLE so that the window is "Not Clickable" and you can see and work with windows that are behind it. The example in this thread is a perfect testing ground though, because what I want is basically to move the dot around, with a transparent background, and have it not ghost. This works perfectly if you do not use the backbuffering technique, and just draw directly on the $hGraphic, but there is some flickering, especially with older PC's.

Maybe this is not possible using this technique?

You know what, forget my question... I have some kind of other problem where my text looks funny but in this example the text looks right. I have too much code to post, so I'll just have to drill down and figure out where I'm going wrong?

Example code, text looks OK.

#include <GDIPlus.au3>
#include <misc.au3>
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate("GDI+ Sample!", 400, 400,100,100,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW,Not($WS_EX_WINDOWEDGE),Not($WS_EX_CLIENTEDGE)))
        GUISetBkColor($hwnd,0x000000)
        WinSetTrans($hwnd,"",80)

GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(400, 400, $graphics);  This is actually the buffer
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer
$white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$hFormat = _GDIPlus_StringFormatCreate ()
$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
$hFontxx = _GDIPlus_FontCreate ($hFamily, 18, 2)
$hBrush = _GDIPlus_BrushCreateSolid (0x99FF0000)


$x = 175
$y = 175

Do
    
    #Region Animation Logic
    If _IsPressed("25") Then; Left arrow
        $x -= 5
    EndIf
    
    If _IsPressed("26") Then; up arrow
        $y -= 5
    EndIf
    
    If _IsPressed("27") Then; right arrow
        $x += 5
    EndIf
    
    If _IsPressed("28") Then; down arrow
        $y += 5
    EndIf
    #EndRegion Animation Logic
    

    
    _GDIPlus_GraphicsClear($backbuffer,0x05000000); Always start with a clean buffer!

    $tLayout = _GDIPlus_RectFCreate (4,0,0,0)
    $aInfo = _GDIPlus_GraphicsMeasureString ($backbuffer, "Text", $hFontxx, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,"Text",$hFontxx,$aInfo[0],$hFormat,$hBrush)

    _GDIPlus_GraphicsFillEllipse($backbuffer, $x, $y, 50, 50, $white)
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 400, 400); Present buffer to screen!
    Sleep(15)
Until False

Func close()
    _GDIPlus_BrushDispose($white)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>close

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

Arterie

I saw an impressive raycasting script recently I thought you should look at. I believe it used to be posted here.

If the script was yours, keep going. I await its completion.

Fr0zT

I was not aware of that trailing ghost effect method. Fiddled with it as one does to see the possibilities and what does what.

Check out the optimizing of the _IsPressed() function in the WinMove(), "$x += ", and "$y += " lines.

The Tool Tip was added only for user info.

;
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <string.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

;Modified from
; http://www.autoitscript.com/forum/index.php?s=&showtopic=80127&view=findpost&p=693089

Opt("GUIOnEventMode", 1)
$hwnd = GUICreate("GDI+ Sample!", 400, 400, 100, 100, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TRANSPARENT, _
        $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, Not ($WS_EX_WINDOWEDGE), Not ($WS_EX_CLIENTEDGE)))
GUISetBkColor($hwnd, 0x000000)
WinSetTrans($hwnd, "", 80)

GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd); This is the graphics, ($graphics) of the display medium (GUI).
$bitmap = _GDIPlus_BitmapCreateFromGraphics(400, 400, $graphics);  This is actually the buffer- a bitmap in memory.
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer - graphics of the buffer.
$white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$tLayout = _GDIPlus_RectFCreate(170, 181, 60, 28)
$hFontxx = _GDIPlus_FontCreate($hFamily, 18, 3)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

$x = 175
$y = 175

Do  
    $aP = WinGetPos($hwnd); For ToolTip use
    $aMP = MouseGetPos() ; For ToolTip use
    
    Select  
        Case _IsPressed("11"); CTRL key - Hold down to move GUI with arrow keys.
            Do
                $aP = WinGetPos($hwnd)
                WinMove($hwnd, "", $aP[0] - _IsPressed("25") + _IsPressed("27"), $aP[1] + _IsPressed("28") - _IsPressed("26"))
            Until Not _IsPressed("11")
        Case _IsPressed("1B"); Esc to exit
            close()
        Case _WinAPI_PtInRectEx($aMP[0], $aMP[1], $aP[0], $aP[1], $aP[2], $aP[3]); For ToolTip use
            ToolTip("Use arrow keys to move white dot" & @CRLF & "Hold Ctrl key down and use arrow keys to move window." & _
            @CRLF & "Esc to exit")
        Case Not _WinAPI_PtInRectEx($aMP[0], $aMP[1], $aP[0], $aP[1], $aP[2], $aP[3]); For ToolTip use
            ToolTip("")             
    EndSelect

;0x33000000 gives ghost trail effect. Each "Do" loop, 1/5 of the transparency of the
;existing graphics ($backbuffer) of bitmap ($bitmap) is cleared.
;0xFF000000 removes this effect because the alpha color channel to fully opaque. The bitmap's graphics are completely cleared.
    _GDIPlus_GraphicsClear($backbuffer, 0xFF000000); Always start with a clean buffer! Unless using a moving, ghosting effect.
    
    $x += 5 * (_IsPressed("27") - _IsPressed("25"));Right and left arrows
    $y += 5 * (_IsPressed("28") - _IsPressed("26"));Down and up arrows
    _GDIPlus_GraphicsFillEllipse($backbuffer, $x, $y, 50, 50, $white)

    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer, "Text", $hFontxx, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer, "Text", $hFontxx, $aInfo[0], $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 400, 400); Present buffer to screen!

Until Not Sleep(50);False

Func close()
    _GDIPlus_FontDispose($hFontxx)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($white)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>close

; For ToolTip use
Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iWidth, $iHeight)
    Local $aResult, $tagREC = "int Left;int Top;int Right;int Bottom"
    Local $tRect = DllStructCreate($tagREC)
    DllStructSetData($tRect, "Left", $iLeft)
    DllStructSetData($tRect, "Top", $iTop)
    DllStructSetData($tRect, "Right", $iLeft + $iWidth)
    DllStructSetData($tRect, "Bottom", $iTop + $iHeight)
    $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
    If @error Then Return SetError(@error, 0, False)
    Return $aResult[0] <> 0
EndFunc  ;==>_WinAPI_PtInRectEx
;
Posted (edited)

OK I am back again after no progress, this time with some Code to formally show my problem... I've ripped out the essential GDI parts from various spots in my program to form this ugly representation....

Drawing directly to $hGraphic works fine, but using the backbuffer technique I have problems here with text (and colors, and some flickering)

Alter the $USE_ME line to see the problem.

#include <GDIPlus.au3>; this is where the magic happens, people

_GDIPlus_Startup()

Global $hFormat = _GDIPlus_StringFormatCreate ()
Global $vFormat = _GDIPlus_StringFormatCreate (0x0002)
Global $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
Global $hFontxi = _GDIPlus_FontCreate ($hFamily, 8, 2)
Global $hFontxx = _GDIPlus_FontCreate ($hFamily, 11, 2)

$displayBgColor = 0x11FF11
$displayForColor = 0xDFDF21
$displayTransparency = 155
$hWnd = GUICreate("GUI", 500, 500, 100, 100,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW,Not($WS_EX_WINDOWEDGE),Not($WS_EX_CLIENTEDGE)))
GUISetBkColor($hWnd,0x000000)
GUISetState(@SW_SHOW)
_API_SetLayeredWindowAttributes($hWnd, $displayBgColor,$displayTransparency,True)
$hBrush = _GDIPlus_BrushCreateSolid (0xFFFF0000)
$sBrush = _GDIPlus_BrushCreateSolid (0xFF000000 + $displayForColor)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 1)
$hGridPen = _GDIPlus_PenCreate (0xFF00FF00)
_GDIPlus_PenSetDashStyle ($hGridPen, $GDIP_DASHSTYLEDASH)
$bgColor = ($displayTransparency * 16777216) + $displayBgColor
 $bitmap = _GDIPlus_BitmapCreateFromGraphics(500, 500, $hGraphic);  This is actually the buffer
 $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer

;Switch this to test problem, $hGraphic is how it SHOULD look
$USE_ME = $hGraphic
;$USE_ME = $backbuffer

_GDIPlus_GraphicsClear ($USE_ME, $bgColor); Start Fresh
For $y = 0 to 500 step 50
    for $n = 0 to 500 step 50
        $tLayout = _GDIPlus_RectFCreate ($n,$y,0,0)
        $aInfo = _GDIPlus_GraphicsMeasureString ($USE_ME, "Text", $hFontxx, $tLayout, $hFormat)
        _GDIPlus_GraphicsDrawStringEx($USE_ME,"Text",$hFontxx,$aInfo[0],$hFormat,$hBrush)
        _GDIPlus_GraphicsDrawLine($USE_ME, 0, 0, 500, 0, $hGridPen)
    Next
    for $n = 0 to 500 step 50
        $tLayout = _GDIPlus_RectFCreate ($y,$n,0,0)
        $aInfo = _GDIPlus_GraphicsMeasureString ($USE_ME, "More Text", $hFontxi, $tLayout, $vFormat)
        _GDIPlus_GraphicsDrawStringEx($USE_ME,"More Text",$hFontxi,$aInfo[0],$vFormat,$sBrush)
    Next
Next
    If $USE_ME = $backbuffer Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $bitmap, 0, 0, 500, 500); Present buffer to screen!

while 1
WEnd
            
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    Local Const $LWA_ALPHA = 0x2
    Local Const $LWA_COLORKEY = 0x1
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, 0, 0)
        Case Else
            Return 1
    EndSelect
EndFunc ;==>_API_SetLayeredWindowAttributes
Edited by Fr0zT

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

OK, I have one part solved here. Using _WinAPI_RedrawWindow($hWnd). Here is a quick sample using transparencies with a backbuffer, and text that looks right. Of coarse now there is flickering because of redrawing(a lot), which kind of defeats the whole point to backbuffering, but on the plus side at least you have an image that can be moved around without having to re-render everything. I think that involving transparencies, this might be as close as it gets, but I hope I'm wrong about that.

#include <GDIPlus.au3>; this is where the magic happens, people

_GDIPlus_Startup()

Global $hFormat = _GDIPlus_StringFormatCreate ()
Global $vFormat = _GDIPlus_StringFormatCreate (0x0002)
Global $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
Global $hFontxi = _GDIPlus_FontCreate ($hFamily, 8, 2)
Global $hFontxx = _GDIPlus_FontCreate ($hFamily, 11, 2)

$displayBgColor = 0x00FF00
$displayForColor = 0xDFDF21
$displayTransparency = 155
$hWnd = GUICreate("GUI", 500, 500, 100, 100,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW,Not($WS_EX_WINDOWEDGE),Not($WS_EX_CLIENTEDGE)))
_API_SetLayeredWindowAttributes($hWnd, 0,$displayTransparency,True)
$bgColor = ($displayTransparency * 16777216) + $displayBgColor
GUISetBkColor(0,$hWnd)
GUISetState(@SW_SHOW)
$hBrush = _GDIPlus_BrushCreateSolid (0xFFFF0000)
$sBrush = _GDIPlus_BrushCreateSolid (0xFF000000 + $displayForColor)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 1)
_GDIPlus_GraphicsClear ($hGraphic, $bgColor); Start Fresh
$hGridPen = _GDIPlus_PenCreate (0xFF00FF00)
_GDIPlus_PenSetDashStyle ($hGridPen, $GDIP_DASHSTYLEDASH)
 $bitmap = _GDIPlus_BitmapCreateFromGraphics(500, 500, $hGraphic);  This is actually the buffer
;_GDIPlus_GraphicsSetSmoothingMode($bitmap, 1)
 $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer

;Switch this to test problem
;$USE_ME = $hGraphic
$USE_ME = $backbuffer

_GDIPlus_GraphicsClear ($USE_ME, $bgColor); Start Fresh
For $y = 0 to 500 step 50
    for $n = 0 to 500 step 50
        $tLayout = _GDIPlus_RectFCreate ($n,$y,0,0)
        $aInfo = _GDIPlus_GraphicsMeasureString ($USE_ME, "Text", $hFontxx, $tLayout, $hFormat)
        _GDIPlus_GraphicsDrawStringEx($USE_ME,"Text",$hFontxx,$aInfo[0],$hFormat,$hBrush)
        _GDIPlus_GraphicsDrawLine($USE_ME, 0, 0, 500, 0, $hGridPen)
    Next
    for $n = 0 to 500 step 50
        $tLayout = _GDIPlus_RectFCreate ($y,$n,0,0)
        $aInfo = _GDIPlus_GraphicsMeasureString ($USE_ME, "More Text", $hFontxi, $tLayout, $vFormat)
        _GDIPlus_GraphicsDrawStringEx($USE_ME,"More Text",$hFontxi,$aInfo[0],$vFormat,$sBrush)
    Next
Next
$c = 500
while 1
    If $USE_ME = $backbuffer Then
        _WinAPI_RedrawWindow($hWnd);                Without one of these,Text will look funny.
        ;GUISetBkColor(0,$hWnd);                        Virtually the same effect
        ;_GDIPlus_GraphicsClear ($hGraphic, 0xFF000000);    Same
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $bitmap, $c, 0, 500, 500)
    EndIf
    $c-=1
    If $c <= -500 Then Exit
WEnd

Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    Local Const $LWA_ALPHA = 0x2
    Local Const $LWA_COLORKEY = 0x1
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, 0, 0)
        Case Else
            Return 1
    EndSelect
EndFunc ;==>_API_SetLayeredWindowAttributes

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

OK, I have one part solved here. Using _WinAPI_RedrawWindow($hWnd). Here is a quick sample using transparencies with a backbuffer, and text that looks right. Of coarse now there is flickering because of redrawing(a lot), which kind of defeats the whole point to backbuffering, but on the plus side at least you have an image that can be moved around without having to re-render everything. I think that involving transparencies, this might be as close as it gets, but I hope I'm wrong about that.

You could try this.

To get rid of the flickering:-

Delete or comment out line#25, _GDIPlus_GraphicsClear ($hGraphic, $bgColor); Start Fresh

Delete or comment out line#53, _WinAPI_RedrawWindow($hWnd); Without one of these,Text will look funny.

To reduce CPU usage add Sleep(20) to within While - Wend loop.

This worked on my XP.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...