Jump to content

GDI+ scrubby redraw


 Share

Recommended Posts

Adapted from Malkeys post at -- http://www.autoitscript.com/forum/index.php?showtopic=120273&view=findpost&p=835652

This scrubbily draws the new picture over the existing, before I add more pics and clutter I would like advice...

-- currently you have to show each image - I will probably build the arrays beforehand and have them prepositioned in the script

*unless of course there is a more efficient way

my thought is to have scrubbily drawn icons as i am installing things --- hopefully with the random redraw leaving small pieces behind each time depending on the amount of time per install, such that the last picture could potentially have a small smattering of pixels from all previous.

Thanks for any ideas.

#include <GUIConstants.au3>
#include <Array.au3>
#include <Misc.au3>


;======== load image into array ==============
SplashImageOn("", RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & _
        "\Examples\GUI\merlin.gif", 90, 90, 0, 0, 1)

Dim $Array[90][90]

For $B = 0 To UBound($Array, 1) - 1
    For $C = 0 To UBound($Array, 2) - 1
        $Array[$B][$C] = "0x" & Hex(PixelGetColor($B + 1, $C + 1), 6)
    Next
Next

;~ _arraydisplay ($array)
SplashOff()


SplashImageOn("", RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & _
        "\Examples\GUI\msoobe.jpg", 90, 90, 0, 0, 1)

Dim $BArray[90][90]

For $B = 0 To UBound($BArray, 1) - 1
    For $C = 0 To UBound($BArray, 2) - 1
        $BArray[$B][$C] = "0x" & Hex(PixelGetColor($B + 1, $C + 1), 6)
    Next
Next



;========= Draw array of pixels to desktop at mouse button down ===============
Local $aMPos, $dc

$start1 = TimerInit ()

$dif = timerdiff($start1)

While timerdiff($start1) < 7000
            Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
            For $B = 0 To Random(UBound($Array, 1)) - 1
                For $C = 0 To Random(UBound($Array, 2)) - 1
                    _PixelSetColor($B + 1, $C + 1, $Array[$B][$C])

                Next

            Next
            DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])

WEnd

While timerdiff($start1) >= 7000
                If timerdiff($start1) > 15000 Then
exit
endif
            Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
            For $B = 0 To Random(UBound($BArray, 1)) - 1
                For $C = 0 To Random(UBound($BArray, 2)) - 1
                    _PixelSetColor($B + 1, $C + 1, $BArray[$B][$C])
                Next
            Next
            DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])

WEnd


; Modified from http://www.autoitscript.com/forum/index.php?showtopic=7315&view=findpost&p=178779
Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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