本文介绍了转换乘法图像(在listview中加载)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,

我正在编写一个应用程序,应该将图像列表转换为自己的大小(x / y)和格式

代码有效,我可以预览,转换图像并更改其大小(x / y)和输出格式,



我通过openfiledialog打开文件路径作为字符串,并将它们列在一个listview

示例:c\users \mick \ download = \\ Image.jpg

项目:c\users \mick \downloads

sub1:\ image001

sub2:.jpg



问题是:

转换1图像顺利,它的工作方式我想要它

选择多于1个图像然后转换它,给我所有相同的图像作为顶部选择



例如:

我选择Image001,Image002,Image003,Image004,Image005和Image006

我转换所选图像,但它会给我6x Image001 ...



代码如下,有人可以看一下吗?

谢谢你...







Ok,
I''m writing a app that should convert a list of images to own size (x/y) and format
The code works, i can preview, convert the image and change its size (x/y), and output format,

I open the filepath as string via openfiledialog, and list them in a listview
example: c\users\mick\download\Image001.jpg
Item: c\users\mick\downloads
sub1: \image001
sub2: .jpg

Problem is:
Converting 1 image goes well, it works the way i want it
Selecting more then 1 image and then convert it, gives me all the same images as top selected

For example:
I select Image001, Image002, Image003, Image004, Image005, and Image006
I convert the selected images, but it wil give me 6x Image001...

the code is below, can somebody please have a look at it?
Thank you...



''Opening more then 1 file''
        Dim ofd As New OpenFileDialog()
        ofd.Multiselect = True

        If ofd.ShowDialog() = DialogResult.OK Then
            For Each file In ofd.FileNames

                Dim path As String = System.IO.Path.GetDirectoryName(file)
                Dim extension As String = System.IO.Path.GetExtension(file)
                Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(file)

                Dim lvitem As ListViewItem = ListView1.Items.Add(path)
                lvitem.SubItems.Add(filename)
                lvitem.SubItems.Add(extension)

            Next

        End If


''Code for converting and saving''
Dim i As Integer
For Each item As ListViewItem In ListView1.SelectedItems
    i = item.Index

''Convert size''
    Dim original As Image = Image.FromFile(ListView1.SelectedItems(0).Text & "\" & ListView1.SelectedItems(0).SubItems(1).Text & ListView1.SelectedItems(0).SubItems(2).Text)
    Dim newbmp As New Bitmap(original, 1600, 1200)
        Dim gp As Graphics = Graphics.FromImage(newbmp)

''Check if the directory exists''
        Dim strfilename As String
        If Not My.Computer.FileSystem.DirectoryExists(C:\Users\Mick\Desktop\Screenshot) Then
            My.Computer.FileSystem.CreateDirectory(C:\Users\Mick\Desktop\Screenshot)
        End If

        ''Count how many files are in the directory''
        Dim counter = My.Computer.FileSystem.GetFiles(C:\Users\Mick\Desktop\Screenshot)
        Dim intCount As Integer
        intCount = CStr(counter.Count)

''Output name and file format''
    If ComboBox1.SelectedItem = ".Jpeg" Then
        strfilename = "Image" & intCount + 1
        newbmp.Save(C:\Users\Mick\Desktop\Screenshot\ & strfilename & .jpeg, System.Drawing.Imaging.ImageFormat.Jpeg)
end if

推荐答案


这篇关于转换乘法图像(在listview中加载)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:27