Picturebox Speichern

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von Zukatane.

    Picturebox Speichern

    ich habe ein kleines problem:

    ich habe eine picturebox (PB1)

    ich benutze diesen code um diese zu füllen:

    VB.NET-Quellcode

    1. For i = 0 To 130
    2. PB1.CreateGraphics().DrawLine(Pens.Gray, 0, i, 600, i)
    3. Next
    4. PB1.CreateGraphics().DrawString("Cpu-Auslastung: " & Label2.Text, Label4.Font, Brushes.Black, 12, 39)
    5. PB1.CreateGraphics().DrawString("Ram-Auslastung: " & Label5.Text, Label4.Font, Brushes.Black, 12, 71)
    6. PB1.CreateGraphics().DrawString(System.DateTime.Now, Label4.Font, Brushes.Black, 393, 104)


    Dann habe ich versucht so zu speichern:

    VB.NET-Quellcode

    1. Dim pic As New Bitmap(Me.PB1.Width, Me.PB1.Height)
    2. Using g As Graphics = Graphics.FromImage(pic)
    3. g.Clear(PB1.BackColor)
    4. End Using
    5. pic.Save("C:\Users\---\Pictures\1.bmp", System.Drawing.Imaging.ImageFormat.Jpeg)


    aber raus kommt ein leeres bild! wie kann ich das geschriebene auch mitspeichern?


    und ich habe es auich nochmal so getestet:

    VB.NET-Quellcode

    1. PB1.Image.Save("C:\Users\---\Pictures\df.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)


    dann kommt aber dieser fehler :

    VB.NET-Quellcode

    1. System.NullReferenceException wurde nicht behandelt.
    2. Message="Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."
    3. Source="SystemTool"
    4. StackTrace:
    5. bei SystemTool.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\Users\%Username%\Pictures\SystemTool\SystemTool\Form1.vb:Zeile 47. bei System.Windows.Forms.Timer.OnTick(EventArgs e) bei System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(ApplicationContext context) bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) bei SystemTool.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81. bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart()
    6. InnerException:

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Zukatane“ ()