Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to preview multiple page or .tiff image using ms visual Basic 2010?

user-image
Question added by Mohammed Taha , IT Manager - Chairman Office , egypt air
Date Posted: 2014/11/26
Mohamed Kaleel
by Mohamed Kaleel , IT MANAGER , Chemanol

Try This ,

 

Preview using PictureBox 

 

Imports System.IO

Imports System.Drawing.Imaging

 

Public Class Form1

 

    Dim fs As FileStream

    Dim srcBmp As Bitmap

    Dim totalPages As Integer

    Dim currentPage As Integer =0

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        fs = File.Open("C:\\Temp\\in.tif", FileMode.Open, FileAccess.Read)

        srcBmp = CType(Bitmap.FromStream(fs), Bitmap)

        totalPages = CInt(srcBmp.GetFrameCount(FrameDimension.Page) -1)

        srcBmp.SelectActiveFrame(FrameDimension.Page, currentPage)

        uxPicture.Image = srcBmp

    End Sub

 

    Private Sub uxPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxPrevious.Click

        If currentPage >0 Then

            currentPage -=1

            srcBmp.SelectActiveFrame(FrameDimension.Page, currentPage)

            uxPicture.Refresh()

        End If

    End Sub

 

    Private Sub uxNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxNext.Click

        If currentPage < totalPages Then

            currentPage +=1

            srcBmp.SelectActiveFrame(FrameDimension.Page, currentPage)

            uxPicture.Refresh()

        End If

    End Sub

 

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

        fs.Close()

    End Sub

End Class

More Questions Like This