Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Extracting Images from a zip file direct to a image control.

Sort Posts: Previous Next
  •  11-09-2007, 11:03 AM Post no. 5737

    Extracting Images from a zip file direct to a image control.

    Hi,
    I have a zip file containing a large number .bmp files.

    I would like to extract a bmp out of a zip file into a VB picture or image control, without extract to a file first. (I want this to work as fast as possible.)

    Is there a way to extract a .bmp file out of a zip file directly into memory and then somehow transfer the memory copy of the bmp directly into a picture or image control?
  •  11-14-2007, 5:27 PM Post no. 5738 in reply to 5737

    Re: Extracting Images from a zip file direct to a image control.

    Here is a little code snippet that worked fine for me. On my form I had a System.Windows.Forms.PictureBox ("pictureBox1") and a ComboBox ("comboBox1"):

    <code>
    Private files As AbstractFile()

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim zipFile As AbstractFile = New DiskFile(Application.StartupPath + "\archive.zip")

    Dim archive As New ZipArchive(zipFile)

    files = archive.GetFiles(True, "*.bmp")

    For Each file As AbstractFile In files
    comboBox1.Items.Add(file.Name)
    Next

    If comboBox1.Items.Count > 0 Then
    comboBox1.SelectedIndex = 0

    loadImage(files(comboBox1.SelectedIndex))
    End If
    End Sub

    Private Sub loadImage(ByVal file As AbstractFile)
    pictureBox1.Image = New Bitmap(file.OpenRead())
    End Sub
    </code>
    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.