Hallo und guten abend alle zusammen, ich möchte alle bilder in der listbox1 kleinrechnen, dazu lese exifdaten aus originalgroße orientierung usw..
dann lasse ich es die Größe anpassen und speichere es ab.
da tauchen dann gleich mehrere Probleme auf,
1. er macht nur 10 bilder und sagt dann Reiter fertig es sind aber 100 bilder ( in listbox1 sind alle 100 angezeigt und listbox2 ebnso
2. er macht mir beim berechnen das Poprgrammfenster weiss und zeigt nix an
ich habe schon x versuche gemacht aber nix geht.. hier folgt der Quellcode
dank schon mal ... mit freundlichen Grüße Ronaldl
dann lasse ich es die Größe anpassen und speichere es ab.
da tauchen dann gleich mehrere Probleme auf,
1. er macht nur 10 bilder und sagt dann Reiter fertig es sind aber 100 bilder ( in listbox1 sind alle 100 angezeigt und listbox2 ebnso
2. er macht mir beim berechnen das Poprgrammfenster weiss und zeigt nix an
ich habe schon x versuche gemacht aber nix geht.. hier folgt der Quellcode
VB.NET-Quellcode
- 'Bilddaten in listbox1 ablegen
- Dim dir As New DirectoryInfo(Label1.Text)
- Dim stb0 As String = "IMG_" & Label4.Text & ".JPG"
- Dim stb As String = Replace(stb0, " ", "")
- Dim enb0 As String = "IMG_" & Label5.Text & ".JPG"
- Dim enb As String = Replace(enb0, " ", "")
- Dim files = From file In dir.GetFiles() _
- Where file.Name.ToString >= stb And file.Name.ToString <= enb _
- Select file
- For Each entry In files
- Dim en0 As String = dir.ToString & "\" & entry.ToString
- ListBox1.Items.Add(en0)
- Next
- Dim Kamera As String = ""
- Dim ori As Long
- Dim ow As Long
- Dim oh As Long
- Dim azbi As Integer = ListBox1.Items.Count - 1
- Label16.Text = azbi
- For iz = 0 To azbi
- With ListBox1.Items
- 'originalgröße der bilder
- Label12.Text = ListBox1.Items(iz).ToString
- Dim Image As Image = Image.FromFile(Label12.Text)
- Dim enc As Encoding = Encoding.Default
- 'PictureBox1.Image = Image
- For Each Info As PropertyItem In Image.PropertyItems
- Select Case Info.Id ' Id ist dezimal
- Case 272 ' ID für Kameramodell / Info.Type 2
- Kamera = enc.GetString(Info.Value, 0, Info.Len - 1)
- Case 274 ' ID für Kameramodell / Info.Type 2
- ori = BitConverter.ToInt16(Info.Value, 0)
- Case 40962 ' (Hex A002) Bildbreite in Pixel / Info.Type 3 (LONG)
- ow = BitConverter.ToInt16(Info.Value, 0)
- 'Label10.Text = BitConverter.ToInt32(Info.Value, 0)
- Case 40963 ' (Hex A003) Bildhöhe in Pixel / Info.Type 3 (LONG)
- oh = BitConverter.ToInt16(Info.Value, 0)
- 'Label11.Text = BitConverter.ToInt32(Info.Value, 0)
- Case Else
- Debug.WriteLine(Info.Id.ToString & " (" & Info.Id.ToString("X") & ") " & Info.Type.ToString)
- End Select
- Next
- Dim imgRatio As Single = CSng(ow / oh)
- Dim odata As String = Kamera & " " & ow.ToString & " X " & oh.ToString & " ratio " & imgRatio.ToString & " ori " & ori.ToString
- ListBox2.Items.Add(odata)
- Dim imgWidth As Integer = ow
- Dim imgHeight As Integer = oh
- If ori = 8 Then
- Dim maxWidthh As Integer = 500 / imgRatio
- Dim maxHeighth As Integer = 500
- Dim oBitmap As Bitmap = Image.FromFile(Label12.Text)
- Dim oImage As New Bitmap(maxHeighth, maxWidthh)
- ' Bild interpolieren, damit die Qualität erhalten bleibt
- Using g As Graphics = Graphics.FromImage(oImage)
- g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
- g.DrawImage(oBitmap, New Rectangle(0, 0, maxHeighth, maxWidthh))
- End Using
- With PictureBox2
- ' PictureBox einrichten
- oImage.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = oImage
- End With
- Else
- Dim maxWidthb As Integer = 500 * imgRatio
- Dim maxHeightb As Integer = 500
- Dim oBitmap As Bitmap = Image.FromFile(Label12.Text)
- Dim oImage As New Bitmap(maxWidthb, maxHeightb)
- PictureBox2.Image = oImage
- ' Bild interpolieren, damit die Qualität erhalten bleibt
- Using g As Graphics = Graphics.FromImage(oImage)
- g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
- g.DrawImage(oBitmap, New Rectangle(0, 0, maxWidthb, maxHeightb))
- End Using
- Dim l3 As Integer = Label12.Text.Length
- Dim l4 As Integer = l3 - 15
- Dim im As String = Label12.Text.Substring(l4, 15)
- Dim im1 As String = "\turniere\testturnier\2.0\thumbs" & im
- Dim thumb As String = Label2.Text '& "\" ' & im
- Label15.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
- Dim img As Image = oImage
- img.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), im), System.Drawing.Imaging.ImageFormat.Jpeg)
- ProgressBar1.Maximum = azbi + 1
- ProgressBar1.Value += 1
- Label11.Text = ProgressBar1.Value / ProgressBar1.Maximum * 100 & " %"
- Label13.Text = ProgressBar1.Value
- End If
- End With
- Next
- ProgressBar1.Value = 0
- Dim sourcePath As New DirectoryInfo(Label15.Text & "\")
- Dim DestinationPath As String = Label2.Text & "\"
- Dim thumbR As String = Label3.Text & "\" & rord & "\" '& im
- Dim myFiles() As FileInfo = sourcePath.GetFiles()
- For i As Integer = 0 To myFiles.Length - 1
- If Not My.Computer.FileSystem.FileExists(thumbR & myFiles(i).ToString) Then
- myFiles(i).CopyTo(thumbR & myFiles(i).ToString)
- End If
- If Not My.Computer.FileSystem.FileExists(DestinationPath & myFiles(i).ToString) Then
- myFiles(i).MoveTo(DestinationPath & myFiles(i).ToString)
- End If
- Label13.Text = ""
- ProgressBar1.Maximum = myFiles.Length - 1
- ProgressBar1.Value += 1
- Label11.Text = ProgressBar1.Value / ProgressBar1.Maximum * 100 & " %"
- Label13.Text = i.ToString
- Next
- Erase myFiles
- ProgressBar1.Value = 0
- Dim hab As String = "1"
- Dim sqldshb As String = "update startliste set berechnet = " & hab & " where tid = " & wertT & " and pruefnr = " & wertP & " and slid = " & Label10.Text & " "
- Dim con6 As New MySqlConnection
- Dim cmd6 As New MySqlCommand(sqldshb, con6)
- Dim myAdapter6 As New MySqlDataAdapter
- Dim anzahl As Integer
- con6.ConnectionString = "server=localhost;" _
- & "uid=root;" _
- & "pwd=slotmachine;" _
- & "database=lenz"
- con6.Open()
- Try
- anzahl = cmd6.ExecuteNonQuery()
- ProgressBar1.Value = 0
- MsgBox("Reiter fertig")
- con6.Close()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- Label4.Text = ""
- Label5.Text = ""
- Label6.Text = ""
- Label7.Text = ""
- Label8.Text = ""
- Label9.Text = ""
- Label10.Text = ""
- Label12.Text = ""
- Label14.Text = ""
- ListBox1.Items.Clear()
- ListBox2.Items.Clear()
- Button1.PerformClick()
- End Sub
dank schon mal ... mit freundlichen Grüße Ronaldl