GDI+ Graphic abspeichern

    • Offizieller Beitrag

    Wie kann man eine mit GDI+ erstellte Graphic abspeichern?

    Das hier klappt nicht:

    Spoiler anzeigen
    [autoit]


    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    $hGui1 = GUICreate('test', 540, 540, -1, 0)
    _GDIPlus_Startup ()
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($hGui1))
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic1, 2)
    $hPen = _GDIPlus_PenCreate(0xcc000000, 2)
    Global $ahBrush[4]
    $ahBrush[0] = _GDIPlus_BrushCreateSolid(0xffffffff)
    $ahBrush[1] = _GDIPlus_BrushCreateSolid(0xff42b8c8)
    $ahBrush[2] = _GDIPlus_BrushCreateSolid(0xffff1a10)
    $ahBrush[3] = _GDIPlus_BrushCreateSolid(0xfffef433)

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

    GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
    GUISetState()

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

    If FileExists(@ScriptDir & '\pic.jpg') Then FileDelete(@ScriptDir & '\pic.jpg')

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

    ; wie kann man die erzeugte Graphic in eine Datei speichern?
    $hImage1 = _GDIPlus_BitmapCreateFromGraphics(540, 540, $hGraphic1) ; das hier
    _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & '\pic.jpg') ; klappt nicht.

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

    Do
    Until GUIGetMsg() = -3

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

    _GDIPlus_PenDispose($hPen)
    For $i = 0 To UBound($ahBrush) -1
    _GDIPlus_BrushDispose($ahBrush[$i])
    Next
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_GraphicsDispose($hGraphic1)
    _GDIPlus_Shutdown()

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

    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, 540, 540, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 30, 30, 480, 480, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 31, 31, 478, 478, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 54, 54, 432, 432, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 55, 55, 430, 430, $ahBrush[0])
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 78, 78, 384, 384)
    _GDIPlus_PenSetColor($hPen, 0xddffffff)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 102, 102, 336, 336, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 103, 103, 334, 334)
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 126, 126, 288, 288, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 127, 127, 286, 286, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 150, 150, 240, 240, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 151, 151, 238, 238, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 174, 174, 192, 192, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 175, 175, 190, 190, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 198, 198, 144, 144, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 199, 199, 142, 142, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 222, 222, 96, 96, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 223, 223, 94, 94, $ahBrush[3])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 246, 246, 48, 48, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 247, 247, 46, 46, $ahBrush[3])
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 258, 258, 24, 24, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 259, 259, 22, 22, $ahBrush[3])
    _GDIPlus_GraphicsDrawLine($hGraphic1, 266, 270, 274, 270, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic1, 270, 266, 270, 274, $hPen)
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Kann dir leider nur bestätigen, dass auch bei mir nur pures Schwarz gespeichert wird.
    Ich sehe adhoc aber keinen Unterschied zum Hilfe-Bsp. - Handle existiert und wird korrekt an _GDIPlus_ImageSaveToFile übergeben.
    :(

    Hier mal eine Alternativlösung, macht zwar nicht glücklich - aber funktioniert.

    Spoiler anzeigen
    [autoit]

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

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

    $hGui1 = GUICreate('test', 540, 540, -1, -1)
    _GDIPlus_Startup ()
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($hGui1))
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic1, 2)
    $hPen = _GDIPlus_PenCreate(0xcc000000, 2)
    Global $ahBrush[4]
    $ahBrush[0] = _GDIPlus_BrushCreateSolid(0xffffffff)
    $ahBrush[1] = _GDIPlus_BrushCreateSolid(0xff42b8c8)
    $ahBrush[2] = _GDIPlus_BrushCreateSolid(0xffff1a10)
    $ahBrush[3] = _GDIPlus_BrushCreateSolid(0xfffef433)

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

    GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
    GUISetState()

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

    If FileExists(@ScriptDir & '\pic.jpg') Then FileDelete(@ScriptDir & '\pic.jpg')

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

    $iHeightTitle = Floor(_WinAPI_GetSystemMetrics(4)/2)
    $hBitmap0 = _ScreenCapture_Capture ("", (@DesktopWidth/2)-270, (@DesktopHeight/2)-270 +$iHeightTitle, _
    (@DesktopWidth/2)+270, (@DesktopHeight/2)+270 -$iHeightTitle, False)
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap0)

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

    ; wie kann man die erzeugte Graphic in eine Datei speichern?
    ;~ $hImage1 = _GDIPlus_BitmapCreateFromGraphics(540, 540, $hGraphic1) ; das hier
    _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & '\pic.jpg') ; klappt nicht.

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

    Do
    Until GUIGetMsg() = -3

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

    _GDIPlus_PenDispose($hPen)
    For $i = 0 To UBound($ahBrush) -1
    _GDIPlus_BrushDispose($ahBrush[$i])
    Next
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_GraphicsDispose($hGraphic1)
    _GDIPlus_Shutdown()

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

    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, 540, 540, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 30, 30, 480, 480, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 31, 31, 478, 478, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 54, 54, 432, 432, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 55, 55, 430, 430, $ahBrush[0])
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 78, 78, 384, 384)
    _GDIPlus_PenSetColor($hPen, 0xddffffff)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 102, 102, 336, 336, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 103, 103, 334, 334)
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 126, 126, 288, 288, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 127, 127, 286, 286, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 150, 150, 240, 240, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 151, 151, 238, 238, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 174, 174, 192, 192, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 175, 175, 190, 190, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 198, 198, 144, 144, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 199, 199, 142, 142, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 222, 222, 96, 96, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 223, 223, 94, 94, $ahBrush[3])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 246, 246, 48, 48, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 247, 247, 46, 46, $ahBrush[3])
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 258, 258, 24, 24, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 259, 259, 22, 22, $ahBrush[3])
    _GDIPlus_GraphicsDrawLine($hGraphic1, 266, 270, 274, 270, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic1, 270, 266, 270, 274, $hPen)
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Danke, für's testen.
    Das heißt, theoretisch sollte mein Beispiel oben funktionieren?
    Ich habe noch nicht viel mit GDI+ gemacht, deshalb war ich am zweifeln, ob das so überhaupt richtig ist.

    Naja, jetzt habe ich das so ähnlich wie von Dir vorgeschlagen (mit _ScreenCapture) gemacht:

    Spoiler anzeigen
    [autoit]


    #include <ScreenCapture.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    $hGui1 = GUICreate('test', 540, 540, -1, 0, $WS_POPUP)
    _GDIPlus_Startup ()
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($hGui1))
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic1, 2)
    $hPen = _GDIPlus_PenCreate(0xcc000000, 2)
    Global $ahBrush[4]
    $ahBrush[0] = _GDIPlus_BrushCreateSolid(0xffffffff)
    $ahBrush[1] = _GDIPlus_BrushCreateSolid(0xff42b8c8)
    $ahBrush[2] = _GDIPlus_BrushCreateSolid(0xffff1a10)
    $ahBrush[3] = _GDIPlus_BrushCreateSolid(0xfffef433)

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

    GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
    GUISetState()

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

    $sFile = @ScriptDir & '\pic.jpg'
    If FileExists($sFile) Then FileDelete($sFile)

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

    _ScreenCapture_CaptureWnd($sFile, $hGui1)

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

    Do
    Until GUIGetMsg() = -3

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

    _GDIPlus_PenDispose($hPen)
    For $i = 0 To UBound($ahBrush) -1
    _GDIPlus_BrushDispose($ahBrush[$i])
    Next
    _GDIPlus_GraphicsDispose($hGraphic1)
    _GDIPlus_Shutdown()

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

    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = WinGetHandle($hGui1) Then
    _GDIPlus_GraphicsClear($hGraphic1, 0xffffffff)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 30, 30, 480, 480, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 31, 31, 478, 478, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 54, 54, 432, 432, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 55, 55, 430, 430, $ahBrush[0])
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 78, 78, 384, 384)
    _GDIPlus_PenSetColor($hPen, 0xddffffff)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 102, 102, 336, 336, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 103, 103, 334, 334)
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 126, 126, 288, 288, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 127, 127, 286, 286, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 150, 150, 240, 240, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 151, 151, 238, 238, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 174, 174, 192, 192, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 175, 175, 190, 190, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 198, 198, 144, 144, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 199, 199, 142, 142, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 222, 222, 96, 96, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 223, 223, 94, 94, $ahBrush[3])
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 246, 246, 48, 48, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 247, 247, 46, 46, $ahBrush[3])
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphic1, 258, 258, 24, 24, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphic1, 259, 259, 22, 22, $ahBrush[3])
    _GDIPlus_GraphicsDrawLine($hGraphic1, 266, 270, 274, 270, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic1, 270, 266, 270, 274, $hPen)
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]

    So funktioniert's. Danke, BugFix!

    Ich lasse es mal auf "offen". Vielleicht weiß ja einer, ob das auch mit den GDI+ Funktionen klappt...

  • Du könntest das Bild erst auf die Bitmap malen und die dann auf deine GUI:

    Spoiler anzeigen
    [autoit]

    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    $hGui1 = GUICreate('test', 540, 540, -1, 0)
    _GDIPlus_Startup ()
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($hGui1))
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(540, 540, $hGraphic1)
    $hGraphicBuff = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphicBuff, 2)
    $hPen = _GDIPlus_PenCreate(0xcc000000, 2)
    Global $ahBrush[4]
    $ahBrush[0] = _GDIPlus_BrushCreateSolid(0xffffffff)
    $ahBrush[1] = _GDIPlus_BrushCreateSolid(0xff42b8c8)
    $ahBrush[2] = _GDIPlus_BrushCreateSolid(0xffff1a10)
    $ahBrush[3] = _GDIPlus_BrushCreateSolid(0xfffef433)

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

    _GDIPlus_GraphicsFillRect($hGraphicBuff, 0, 0, 540, 540, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 30, 30, 480, 480, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 31, 31, 478, 478, $ahBrush[0])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 54, 54, 432, 432, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 55, 55, 430, 430, $ahBrush[0])
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 78, 78, 384, 384)
    _GDIPlus_PenSetColor($hPen, 0xddffffff)
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 102, 102, 336, 336, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 103, 103, 334, 334)
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 126, 126, 288, 288, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 127, 127, 286, 286, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 150, 150, 240, 240, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 151, 151, 238, 238, $ahBrush[1])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 174, 174, 192, 192, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 175, 175, 190, 190, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 198, 198, 144, 144, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 199, 199, 142, 142, $ahBrush[2])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 222, 222, 96, 96, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 223, 223, 94, 94, $ahBrush[3])
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 246, 246, 48, 48, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 247, 247, 46, 46, $ahBrush[3])
    _GDIPlus_PenSetColor($hPen, 0xcc000000)
    _GDIPlus_GraphicsDrawEllipse($hGraphicBuff, 258, 258, 24, 24, $hPen)
    _GDIPlus_GraphicsFillEllipse($hGraphicBuff, 259, 259, 22, 22, $ahBrush[3])
    _GDIPlus_GraphicsDrawLine($hGraphicBuff, 266, 270, 274, 270, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphicBuff, 270, 266, 270, 274, $hPen)

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

    _GDIPlus_GraphicsDispose($hGraphicBuff)
    _GDIPlus_PenDispose($hPen)
    For $i = 0 To UBound($ahBrush) -1
    _GDIPlus_BrushDispose($ahBrush[$i])
    Next

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

    Global Const $tagPAINTSTRUCT = 'hwnd hDC;' & _
    'int fErase;' & _
    'long rcPaint[4];' & _
    'int fRestore;' & _
    'int fIncUpdate;' & _
    'byte rgbReserved[32];'
    ; Greenhorn
    Func _GDI_BeginPaint($hWnd, $lpPaint)

    Local $aResult = DllCall("user32.dll", 'hwnd', 'BeginPaint', 'hwnd', $hWnd, 'ptr', $lpPaint)
    Return $aResult[0]

    EndFunc

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

    ; Greenhorn
    Func _GDI_EndPaint($hWnd, $lpPaint)

    Local $aResult = DllCall("user32.dll", 'int', 'EndPaint', 'hwnd', $hWnd, 'ptr', $lpPaint)
    Return $aResult[0]
    EndFunc

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

    GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
    GUISetState()

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

    If FileExists(@ScriptDir & '\pic.jpg') Then FileDelete(@ScriptDir & '\pic.jpg')

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

    ; wie kann man die erzeugte Graphic in eine Datei speichern?
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & '\pic.jpg') ; klappt nicht.
    ShellExecute(@ScriptDir & '\pic.jpg')

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

    Do
    Until GUIGetMsg() = -3

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

    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic1)
    _GDIPlus_Shutdown()

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

    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphic1,$hBitmap,0,0)

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

    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]
  • Also, Bilder kann man auf eine Grafik zeichnen, Grafiken aber nicht auf Bilder. Warum das so ist frag ich mich auch.
    _GDIPlus_BitmapCreateFromGraphics erstellt jedenfalls nur eine Bitmap, die von der Farbtiefe her zur Grafik passt, aber kopiert nicht den Inhalt.