从列表框导出下一个图像

时间:2016-03-16 15:19:44

标签: vb.net image listbox export

我正在尝试为我的堂兄(他需要为他的工作)构建一个ImageConverter,以便以下列格式导出图像:1。2500x2500,2.1500x1500和3.800x800。

我只设法以这种格式一次只导出一张图片,但他通常每天有超过50张图片以这种格式转换,所以我添加了一个列表框,这样他就可以将他的图像拖放到列表框中.I确实管理了,但我不知道如何导出列表框中加载的图片,它需要逐个导出。我使用“导出按钮”导出图像的代码在这里:

If (Not System.IO.Directory.Exists("C:\Users\Administrator\Desktop\" + KryptonTextBox1.Text)) Then
    System.IO.Directory.CreateDirectory("C:\Users\Administrator\Desktop\" + KryptonTextBox1.Text)

    Dim picturepath As String

    picturepath = "C:\Users\Administrator\Desktop\" + KryptonTextBox1.Text
    pathtxt.Text = picturepath
End If


Dim fileName As String = KryptonListBox1.SelectedItem.ToString()
Dim pathname As String = OpenFileDialog1.FileName

picturename = Path.GetFileNameWithoutExtension(fileName)
BildNametxt.Text = picturename

'converting picture in 2500x2500 format
Try
    If (Not System.IO.Directory.Exists(pathtxt.Text + "\Amazon")) Then
        System.IO.Directory.CreateDirectory(pathtxt.Text + "\Amazon")
    Else
        PictureBox2500.BackgroundImage.Save(pathtxt.Text + "\Amazon" + "\" + picturename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)


    End If
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

Try
    If (Not System.IO.Directory.Exists(pathtxt.Text + "\1500")) Then
        System.IO.Directory.CreateDirectory(pathtxt.Text + "\1500")
    Else
        PictureBox1500.BackgroundImage.Save(pathtxt.Text + "\1500" + "\" + picturename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    End If

Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

Try

    If (Not System.IO.Directory.Exists(pathtxt.Text + "\800")) Then
        System.IO.Directory.CreateDirectory(pathtxt.Text + "\800")
    Else
        PictureBox800.BackgroundImage.Save(pathtxt.Text + "\800" + "\" + picturename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    End If

Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

MessageBox.Show("Images succesfully converted!")

resizedimage2500.Dispose()
resizedimage1500.Dispose()
resizedimage800.Dispose()

那么我怎样才能对加载的列表框做同样的事情呢?任何帮助都是折旧的!提前致谢

0 个答案:

没有答案