Suche andere möglichkeit zum zwischenspeichern von bildern ..

  • VB.NET

Es gibt 24 Antworten in diesem Thema. Der letzte Beitrag () ist von SpezHacker.

    Suche andere möglichkeit zum zwischenspeichern von bildern ..

    Hallo liebe community,

    Bin auf der suche nach einer möglichkeit Bilder anders zwischen zu speichern als im Clipboard .. Kann mir wer helfen ?
    Das is mein code...

    Spoiler anzeigen
    Private Function ic() As Bitmap
    ic = Nothing
    Dim data As IDataObject
    SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    data = Clipboard.GetDataObject()
    If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    ic = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
    End If
    Return ic
    End Function


    Danke schonmal für eure Hilfe :D

    MfG SH

    Edit: Die Farbe ROT darf nur für Moderationshinweise verwendet werden

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

    Wenn das Programm sie halten soll, kannst Du ja eine

    VB.NET-Quellcode

    1. Dim bmp As Bitmap = New Bitmap(Image)
    2. bmp.Save(PFAD, TYP)
    draus machen und/oder sie auf Platte speichern.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    die bilder kommen von einer webcam und werden später dann verschickt , jedoch hab ich bis jetzt nur die lösung gefunden mit dem clipboard was mich aber stört da man solang das programm läuft nichts kopieren bzw. einfügen kann :( ...
    Komm grad garnich klar mit dem code hier .. der kopiert es in die zwischenablage ich weis aber nicht wie bzw. wo ich es abändern muss ..

    Helft mir bitte :rolleyes:

    Spoiler anzeigen

    VB.NET-Quellcode

    1. '###########################################
    2. Public id As Integer = 0
    3. Public hHwnd As Integer
    4. '###########################################
    5. Public Const SWP_NOZORDER As Short = &H4S
    6. Public Const WS_CHILD As Integer = &H40000000
    7. Public Const WS_VISIBLE As Integer = &H10000000
    8. Public Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
    9. Public Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
    10. Public Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
    11. Public Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
    12. Public Const HWND_BOTTOM As Short = 1
    13. Public Const SWP_NOMOVE As Short = &H2S
    14. Public Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
    15. Public Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
    16. Public Const WM_CAP As Short = &H400S
    17. '#################################################
    18. Dim aident As Boolean = True
    19. Dim col1, col2 As Color
    20. Dim red1, green1, blue1, red2, green2, blue2, red3, green3, blue3 As Integer
    21. Dim thold As Integer = Integer.Parse(50)
    22. Dim ecolor As Color = Color.White
    23. Dim ncolor As Color = Color.Red
    24. Dim dr, dg, db, diff As Integer
    25. Dim Op As Bitmap
    26. Declare Function SMessage Lib "user32" Alias "SendMessageA" (ByVal hw As Integer, ByVal wm As Integer, ByVal wp As Integer, <MarshalAs(UnmanagedType.AsAny)> ByVal lp As Object) As Integer
    27. Declare Function SWP Lib "user32" Alias "SetWindowPos" (ByVal hwd As Integer, ByVal hIA As Integer, ByVal a As Integer, ByVal b As Integer, ByVal ca As Integer, ByVal cb As Integer, ByVal wf As Integer) As Integer
    28. Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
    29. Public Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lwn As String, ByVal ds As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nh As Short, ByVal hwp As Integer, ByVal nID As Integer) As Integer
    30. Public Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wd As Short, ByVal ln As String, ByVal cn As Integer, ByVal lv As String, ByVal cv As Integer) As Boolean
    31. Public Sub Get_Webcam()
    32. Dim ih As Integer = PictureBox1.Height
    33. Dim iw As Integer = PictureBox1.Width
    34. hHwnd = capCreateCaptureWindowA(id, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, PictureBox1.Handle.ToInt32, 0)
    35. If SMessage(hHwnd, WM_CAP_DRIVER_CONNECT, id, 0) Then
    36. SMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
    37. SMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
    38. SMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
    39. SWP(hHwnd, HWND_BOTTOM, 0, 0, PictureBox1.Width, PictureBox1.Height, SWP_NOMOVE Or SWP_NOZORDER)
    40. Else
    41. DestroyWindow(hHwnd)
    42. End If
    43. PictureBox1.Image = ic()
    44. End Sub
    45. Private Function ic() As Bitmap
    46. ic = Nothing
    47. Dim data As IDataObject
    48. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    49. data = Clipboard.GetDataObject()
    50. If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    51. ic = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
    52. End If
    53. Return ic
    54. End Function
    Dann mach es eben so:

    VB.NET-Quellcode

    1. Private Function ic() As BitmapTry Dim a as string = clipboard.text
    2. ic = Nothing
    3. Dim data As IDataObject
    4. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    5. data = Clipboard.GetDataObject()
    6. If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    7. ic = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
    8. End If
    9. Return ic clipboard.text = aCatchReturn nothingEnd Try
    10. End Function



    Dann bleibt die Zwischenablage so wie sie ist.
    aber diese bilder bzw. video wird ja übertragen .. und solang es übertragen wird kann man da nichts anderes in der zwischenablage speichern .. das ist ja das problem .. :(

    wenn keiner eine lösung für meinen code kennst kann mir ja vll. jemand helfen das bild der webcam von diesem beispiel per TCP zu übertragen ..
    dotnet-snippets.de/dns/webcam-…box-anzeigen-SID1370.aspx

    Bekomm das irgendwie ned hin ;(

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

    Option Strict On => Bitmap statt Image
    Dieses Testprogramm auf Grundlage Deines Codes funktioniert einwandfrei.

    VB.NET-Quellcode

    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. Dim bmp As Bitmap = ic()
    3. End Sub
    4. Private Function ic() As Bitmap
    5. ic = Nothing
    6. Dim data As IDataObject
    7. 'SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    8. data = Clipboard.GetDataObject()
    9. If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    10. ic = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap) ' hier Bitmap statt Image
    11. ic.Save("c:\Temp\ttt.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
    12. End If
    13. Return ic
    14. End Function
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Genau das macht Dein Code:

    VB.NET-Quellcode

    1. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0) ' hier wird das externe Programm gebeten, die Zwischenablage mit dem Bildinhalt zu befüllen.
    2. data = Clipboard.GetDataObject()
    Nach der Übertragung kannst Du natürlich das Clipboard löschen:

    VB.NET-Quellcode

    1. Clipboard.Clear()
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    aber wenn man in der zeit wo die webcam daten sendet etwas kopieren will z.B. einen text dann geht das nicht .. und ich will halt das das bild übertragen werden kann ohne die zwischenablage zu nutzen ... das ist ja mein problem .. -.-
    Dann musst Du sehen, dass Du dem externen Programm die Bildinformation anders entlocken kannst.
    Bisher hast Du nur dies hier gezeigt:

    VB.NET-Quellcode

    1. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    was ich für absolut unelegant halte, um nicht grottenschlecht sagen zu müssen.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Wer/Was ist hHwnd aus der Zeile

    VB.NET-Quellcode

    1. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    Du kommunizierst doch mit diesem Fenster. Ich kenne es nicht.
    Also lass was sehen, dann wird Dir geholfen.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    ich hab den kompletten code für die kommunikation mit der webcam weiter oben gepostet ...

    aber hier is der code nochmal :

    Spoiler anzeigen

    VB.NET-Quellcode

    1. '###########################################
    2. Public id As Integer = 0
    3. Public hHwnd As Integer
    4. '###########################################
    5. Public Const SWP_NOZORDER As Short = &H4S
    6. Public Const WS_CHILD As Integer = &H40000000
    7. Public Const WS_VISIBLE As Integer = &H10000000
    8. Public Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
    9. Public Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
    10. Public Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
    11. Public Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
    12. Public Const HWND_BOTTOM As Short = 1
    13. Public Const SWP_NOMOVE As Short = &H2S
    14. Public Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
    15. Public Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
    16. Public Const WM_CAP As Short = &H400S
    17. '#################################################
    18. Dim aident As Boolean = True
    19. Dim col1, col2 As Color
    20. Dim red1, green1, blue1, red2, green2, blue2, red3, green3, blue3 As Integer
    21. Dim thold As Integer = Integer.Parse(50)
    22. Dim ecolor As Color = Color.White
    23. Dim ncolor As Color = Color.Red
    24. Dim dr, dg, db, diff As Integer
    25. Dim Op As Bitmap
    26. Declare Function SMessage Lib "user32" Alias "SendMessageA" (ByVal hw As Integer, ByVal wm As Integer, ByVal wp As Integer, <MarshalAs(UnmanagedType.AsAny)> ByVal lp As Object) As Integer
    27. Declare Function SWP Lib "user32" Alias "SetWindowPos" (ByVal hwd As Integer, ByVal hIA As Integer, ByVal a As Integer, ByVal b As Integer, ByVal ca As Integer, ByVal cb As Integer, ByVal wf As Integer) As Integer
    28. Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
    29. Public Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lwn As String, ByVal ds As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nh As Short, ByVal hwp As Integer, ByVal nID As Integer) As Integer
    30. Public Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wd As Short, ByVal ln As String, ByVal cn As Integer, ByVal lv As String, ByVal cv As Integer) As Boolean
    31. Public Sub Get_Webcam()
    32. Dim ih As Integer = PictureBox1.Height
    33. Dim iw As Integer = PictureBox1.Width
    34. hHwnd = capCreateCaptureWindowA(id, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, PictureBox1.Handle.ToInt32, 0)
    35. If SMessage(hHwnd, WM_CAP_DRIVER_CONNECT, id, 0) Then
    36. SMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
    37. SMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
    38. SMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
    39. SWP(hHwnd, HWND_BOTTOM, 0, 0, PictureBox1.Width, PictureBox1.Height, SWP_NOMOVE Or SWP_NOZORDER)
    40. Else
    41. DestroyWindow(hHwnd)
    42. End If
    43. PictureBox1.Image = ic()
    44. End Sub
    45. Private Function ic() As Bitmap
    46. ic = Nothing
    47. Dim data As IDataObject
    48. SMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
    49. data = Clipboard.GetDataObject()
    50. If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    51. ic = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
    52. End If
    53. Return ic
    54. End Function

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

    VB.NET-Quellcode

    1. hHwnd = capCreateCaptureWindowA(id, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, PictureBox1.Handle.ToInt32, 0)
    Du übergibst PictureBox1 als Darstellungsfenster.
    Kannst Du PictureBox1.Image über VB nicht gleich auslesen?
    Musst Du das Bild über die Zwischenablage zuweisen? Das kommt mir spanisch vor.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Ich beschäftige mich das erste mal mit der Webcam deshalb hab ich auch kein peil wie ich das anders lösen kann -.-
    Will das unbedingt schaffen und wissen wie man das macht damit ich es für später weis und es auch verstehe .. aber komm mit dem code kein stück klar .. ;(

    Helft mir bitte :)