Hi
Ich hab mich mal an einer LED Laufschrift versucht
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Global $iX = 0, $iW, $iStep = 8
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
Global $hGui = GUICreate("LaufSchrift", 800, 200)
GUISetBkColor(0x000000)
GUISetOnEvent(-3, "_Exit")
GUISetState()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBitmapBuffer = _GDIPlus_BitmapCreateFromGraphics(800, 200, $hGraphics)
Global $hGraphicsBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmapBuffer)
_GDIPlus_GraphicsClear($hGraphicsBuffer, 0xFF000000)
Global $hBitmapLed = _CreateLedBitmap($hGraphics, "Dies ist eine Laufschrift!", 800, 200, $iStep, $iStep, 0xFFFFBB00, 0x66111122)
;Global $hBitmapLed = _CreateLedBitmap($hGraphics, "Dies ist eine Laufschrift!", 800, 200, $iStep, $iStep, 0xFF00FF00, 0x66000000)
$iW = @extended
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
[/autoit] [autoit][/autoit] [autoit]While 1
$iX -= $iStep
If $iX + $iW < 0 Then $iX += $iW
_GDIPlus_GraphicsDrawImage($hGraphicsBuffer, $hBitmapLed, $iX, 0)
_GDIPlus_GraphicsDrawImage($hGraphicsBuffer, $hBitmapLed, $iX + $iW, 0)
_WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INTERNALPAINT)
Sleep(20)
WEnd
Func _WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _CreateLedBitmap($hGraphics, $sText, $iW, $iH, $iLedOffSet, $iLedSize, $iOnColor = 0xFFFFBB00, $iOffColor = 0x88111122, $sFont = "Arial")
$sText = StringUpper(StringReplace($sText,@LF,""))
Local $hBrush = _GDIPlus_BrushCreateSolid($iOnColor)
Local $hBrushOff = _GDIPlus_BrushCreateSolid($iOffColor)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iH, 1, 2)
Local $tLayout = _GDIPlus_RectFCreate($iW, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) + $iW
$iWidth -= Mod($iWidth, $iLedOffSet)
Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
DllStructSetData($aInfo[0], "Y", -Round(($iHeight - $iH) / 3))
Local $hBitmapTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Local $hBitmapLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Local $hGraphicsTxt = _GDIPlus_ImageGetGraphicsContext($hBitmapTxt)
Local $hGraphicsLed = _GDIPlus_ImageGetGraphicsContext($hBitmapLed)
_GDIPlus_GraphicsClear($hGraphicsTxt, $iOffColor)
_GDIPlus_GraphicsDrawStringEx($hGraphicsTxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmapTxt, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $Stride = DllStructGetData($BitmapData, "Stride")
Local $Width = DllStructGetData($BitmapData, "Width")
Local $Height = DllStructGetData($BitmapData, "Height")
Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
Local $PixelData, $Color = Hex($iOnColor)
For $row = 0 To $Height - 1 Step $iLedOffSet
For $col = 0 To $Width - 1 Step $iLedOffSet
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
If Hex(DllStructGetData($PixelData, 1)) = $Color Then
_GDIPlus_GraphicsFillEllipse($hGraphicsLed, $col, $row, $iLedSize, $iLedSize, $hBrush)
Else
_GDIPlus_GraphicsFillEllipse($hGraphicsLed, $col, $row, $iLedSize, $iLedSize, $hBrushOff)
EndIf
Next
Next
_GDIPlus_BitmapUnlockBits($hBitmapTxt, $BitmapData)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrushOff)
_GDIPlus_BitmapDispose($hBitmapTxt)
_GDIPlus_GraphicsDispose($hGraphicsTxt)
_GDIPlus_GraphicsDispose($hGraphicsLed)
Return SetExtended($iWidth, $hBitmapLed)
EndFunc ;==>_CreateLedBitmap
Func _Exit()
_GDIPlus_BitmapDispose($hBitmapLed)
_GDIPlus_GraphicsDispose($hGraphicsBuffer)
_GDIPlus_BitmapDispose($hBitmapBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
viel Spaß!
E
Edit: Die Schrift beginnt jetzt außerhalb des Fensters
Mit dem Alphakanal der OffColor kann man übrigens das Nachglühen einstellen 0x66111122
Die OnColor muß den Alphawert 0xFF haben!
Es gibt noch ein paar Bugs, wenn man die Größe des Fensters oder der Leds verändert
das werd ich mir mal ansehen, wenn ich etwas mehr Zeit hab