Bilder in Variablen speichern

  • Hey leute, wieder mal ne Frage:

    ich will nen Programm erstellen, dass bei einem Hotkey wenn ich spiele, 20 screenshots hintereinander macht..

    hab sowas ähnliches mal früher probiert, bin aber kläglich daran verreckt, weil bei jedem screenshot erstmal eine DATEI erstellt werden musste...
    und dass sowas die Performence des Rechners nicht gerade in die höhe treibt kann sich jeder vorstellen...
    also hier meine Frage:

    wie kann ich die einzelnen bilder in Variablen speichern, um am Ende z.B. nur eins Speichern zu wollen...

    hoffe, ich hab mich verständlich ausgedrückt...

    :rock:

    Einmal editiert, zuletzt von Mr_gitarre (13. April 2010 um 18:52)

  • watn, so einfach????

    dankeschööönnn....!!!! :thumbup: :thumbup: :thumbup: :thumbup: :thumbup:

    werd ich gleich morgen probieren...

    ... und darstellen der einzelnen bilder in einem Fenster??

    Einmal editiert, zuletzt von Mr_gitarre (12. April 2010 um 19:51)

  • [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>

    [/autoit][autoit][/autoit][autoit]

    $Var = _ScreenCapture_Capture()

    [/autoit][autoit][/autoit][autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Pic1 = GUICtrlCreatePic($Var, 0, 0, 617, 433, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit][autoit][/autoit][autoit]

    EndSwitch
    WEnd

    [/autoit]

    So einfach funktioniert das leider nicht mit dem darstellen...:(

  • Das macht man auch mit GDI+ hier mal meine Bildschirmlupe als Beispiel.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $iGUIWidth = 100
    $iGUIHeight = 100
    $iCaptureWidth = 50
    $iCaptureHeight = 50

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("Test", $iGUIWidth, $iGUIHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    [/autoit] [autoit][/autoit] [autoit]

    $PosOld = MouseGetPos()
    _ReDraw($PosOld[0], $PosOld[1])

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    _Exit()
    EndSwitch
    If Not ($PosOld[0] = MouseGetPos(0) And $PosOld[1] = MouseGetPos(1)) Then
    _ReDraw($PosOld[0], $PosOld[1])
    $PosOld[0] = MouseGetPos(0)
    $PosOld[1] = MouseGetPos(1)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _ReDraw($PosX, $PosY)
    WinMove($hWnd, "", $PosX + $iCaptureWidth / 2 + 2, $PosY + $iCaptureHeight / 2 + 2)
    $HBITMAP_Capture = _ScreenCapture_Capture("", $PosX - $iCaptureWidth / 2, $PosY - $iCaptureHeight / 2, $PosX + $iCaptureWidth / 2, $PosY + $iCaptureHeight / 2, False)
    $hBitmap_Capture = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP_Capture)
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hBitmap_Capture, 0, 0, $iGUIWidth, $iGUIHeight)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    _GDIPlus_BitmapDispose($hBitmap_Capture)
    _WinAPI_DeleteObject($HBITMAP_Capture)
    EndFunc ;==>_ReDraw

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    AdlibUnRegister()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]
  • ach du scheiße... da seh ich ja überhaupt nich durch...

    ich will doch nur nen einfachen befehl um das Bild in einer Variable als BILD IM FENSTER einzeigen zu lassen....:(


    hiiiiiiilfeeeeeee.....!!!! ;(

    • Offizieller Beitrag

    Versuch es mal so:

    Spoiler anzeigen
    [autoit]

    #include <ScreenCapture.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <ButtonConstants.au3>
    #include <Constants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Var = _ScreenCapture_Capture()

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Pic1 = GUICtrlCreatePic("", 0, 0, 617, 433)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    _SetBitmapToCtrl($Pic1, $Var)
    _WinAPI_DeleteObject ($Var)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $STM_GETIMAGE = 0x0173
    Local Const $BM_SETIMAGE = 0xF7
    Local Const $BM_GETIMAGE = 0xF6
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0x0E
    Local Const $BS_BITMAP = 0x0080
    Local Const $GWL_STYLE = -16

    [/autoit] [autoit][/autoit] [autoit]

    Local $hWnd, $hPrev, $Style, $iCtrl_SETIMAGE, $iCtrl_GETIMAGE, $iCtrl_BITMAP

    [/autoit] [autoit][/autoit] [autoit]

    ; determine control class and adjust constants accordingly
    Switch _WinAPI_GetClassName($CtrlId)
    Case "Button" ; button,checkbox,radiobutton,groupbox
    $iCtrl_SETIMAGE = $BM_SETIMAGE
    $iCtrl_GETIMAGE = $BM_GETIMAGE
    $iCtrl_BITMAP = $BS_BITMAP
    Case "Static" ; picture,icon,label
    $iCtrl_SETIMAGE = $STM_SETIMAGE
    $iCtrl_GETIMAGE = $STM_GETIMAGE
    $iCtrl_BITMAP = $SS_BITMAP
    Case Else
    Return SetError(1, 0, 0)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(2, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; set SS_BITMAP/BS_BITMAP style to the control
    $Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($Style, $iCtrl_BITMAP))
    If @error Then Return SetError(4, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; set image to the control
    $hPrev = _SendMessage($hWnd, $iCtrl_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $hPrev Then _WinAPI_DeleteObject($hPrev)

    [/autoit] [autoit][/autoit] [autoit]

    Return 1
    EndFunc

    [/autoit]
  • vielen dank erstmal für die Lösung doch verstehen kann ich sie nicht... sie ist mir irgendwie undurchsichtig...

    • Offizieller Beitrag

    Einfach eine Variable zu nehmen und mit GUICtrlCreatePic zu verwenden klappt nicht . Eine Variable ist kein Dateiname. ;)

  • Ich habe mir letztens etwas erstellt, um ein Bild im Fenster darzustellen, du darfst aber glaube ich kein HBITMAP übergeben

    [autoit]


    Func _GDIPlus_ImageShow($img,$titel="",$x=-1,$y=-1)
    If $img=0 Then Return -1
    Local $wx,$wy
    If $x=-1 or $x>@DesktopWidth-50 Then
    $x=_GDIPlus_ImageGetWidth($img)
    if $x>@DesktopWidth-50 Then $x=@DesktopWidth-50
    EndIf
    If $y=-1 or $y>@DesktopWidth-50 Then
    $y=_GDIPlus_ImageGetHeight($img)
    if $y>@DesktopWidth-50 Then $y=@DesktopWidth-50
    EndIf
    $wx=$x
    $wy=$y
    Local $gui=GUICreate($titel,$x,$y,Default,Default,BitOR(0x00C00000,0x00080000)) ;bitor($WS_CAPTION,$WS_SYSMENU)
    GUISetState(@SW_SHOW,$gui)
    Local $gra=_GDIPlus_GraphicsCreateFromHWND($gui)
    Local $buffer=_GDIPlus_BitmapCreateFromGraphics($wx,$wy,$gra)
    Local $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
    _GDIPlus_GraphicsSetSmoothingMode($backgra,2)
    _GDIPlus_GraphicsClear($backgra)
    _GDIPlus_GraphicsDrawImageRect($backgra,$img,0,0,$wx,$wy)
    While GUIGetMsg()<>-3 ;$GUI_EVENT_CLOSE
    _WinAPI_RedrawWindow($gui, "", "", 1280) ;$RDW_UPDATENOW + $RDW_FRAME
    _GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$wx,$wy)
    Sleep(10)
    WEnd
    _GDIPlus_GraphicsDispose($backgra)
    _GDIPlus_BitmapDispose($buffer)
    _GDIPlus_GraphicsDispose($gra)
    GUIDelete($gui)
    Return 1
    EndFunc

    [/autoit]
  • ah ok ok ok aha...

    ... *denk denk


    ich glaub ich guck mir nochmal dein Post an Raupi und versuch zu erkennen welcher Befehl jetz nu dafür verantwortlich ist, das bild da ranzuknallen...

    oder du sagst es mir einfach... ;)


    Vielen dank für eure Unterstützung!! :rock: