Hi
Das .NET Framework bietet ja keine Möglichkeit, Images aus Graphics zu erstellen. Hier mal eine Möglichkeit (recht unschön aber wirkunsvoll):
Edit: Fehler behoben. Sry, ist mir erst jetzt aufgefallen...
Gruß
~blaze~
Das .NET Framework bietet ja keine Möglichkeit, Images aus Graphics zu erstellen. Hier mal eine Möglichkeit (recht unschön aber wirkunsvoll):
VB.NET-Quellcode
- Imports System.Runtime.InteropServices
- '...
- <DllImport("gdi32.DLL", EntryPoint:="BitBlt", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
- Private Shared Function BitBlt(ByVal Intptr1 As IntPtr, ByVal Left As Integer, ByVal Top As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Intptr2 As IntPtr, _
- ByVal int1 As Integer, ByVal int2 As Integer, ByVal int3 As Integer) As Boolean
- End Function
- Private Function CreateImageFromGraphics(ByVal Graphics As Graphics, ByVal Bounds As Rectangle) As Image
- Dim graph As Graphics = Nothing
- Dim dc1 As IntPtr = IntPtr.Zero
- Dim dc2 As IntPtr = IntPtr.Zero
- Dim img As Bitmap
- img = New Bitmap(Bounds.Width, Bounds.Height, Graphics)
- graph = Graphics.FromImage(img)
- dc1 = Graphics.GetHdc()
- dc2 = graph.GetHdc()
- BitBlt(dc2, 0, 0, Bounds.Width, Bounds.Height, dc1, 0, 0, 13369376)
- Graphics.ReleaseHdc(dc1)
- graph.ReleaseHdc(dc2)
- Return img
- End Function
Edit: Fehler behoben. Sry, ist mir erst jetzt aufgefallen...
Gruß
~blaze~
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „~blaze~“ ()