Thumbnails and .Net

Example requests & Code samples for GdPicture Toolkits.
Post Reply
shauns
Posts: 21
Joined: Fri May 25, 2007 3:43 pm
Location: North West England

Thumbnails and .Net

Post by shauns » Wed Jan 09, 2008 11:19 am

Hi,

Have you an example of how to generate thumbnail images from in a .Net application. I don't care whether it is VB.Net or C#. By the way Version 5 sounds perfect for what I am doing.

Keep up the great work

regards

Shaun

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Thumbnails and .Net

Post by Loïc » Wed Jan 09, 2008 12:22 pm

Hi shaun.

You can install the full package of the GdPicture Pro SDK: https://www.gdpicture.com/download/downl ... urepro.php

Open the "_Global_sample" project include into the samples/vb.net directory and look the DrawPreview() function wich shows an usage of the MakeThumbnail() method.

Code: Select all

nThumbImageHandle = Imaging1.MakeThumbnail(150, 150)


Regards,

Loïc

shauns
Posts: 21
Joined: Fri May 25, 2007 3:43 pm
Location: North West England

Re: Thumbnails and .Net

Post by shauns » Thu Jan 10, 2008 7:49 pm

Hi Loic,

Sorry, my fault. I should have been more specific. I am trying to do something very similar to your VB6 thumbnail sample but in .Net code. I scan multipage documents and would like to show a thumbnail image of each page similar to adobe reader etc.

I believe that creating a collection of imageviewer objects might be too resource hungry as some of these documents can be over 100 pages in length

regards

Shaun

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Thumbnails and .Net

Post by Loïc » Sun Jan 13, 2008 8:55 pm

Hi Shaun,

I done a conversion from the vb6 thumbnail sample to VB.NET.

- Start a new project.
- Add an AxImaging object to your form (AxImaging1)
- Add an AxGdViewer object to your form (AxGdViewer1)
- Add a Button object (Button1)
- Add a ListView object (ListView1)
- Add an OpenFileDialog object (OpenFileDialog1)
- Add an ImageList object (ImageList1)


And copy this code into Form1:

Code: Select all

Public Class Form1

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        For i As Integer = 0 To ListView1.Items.Count - 1
            If ListView1.Items.Item(i).Selected = True Then
                AxGdViewer1.DisplayFrame(i + 1)
                Return
            End If
        Next
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim nImageID As Long
        Dim nThumbnailID As Long
        Dim nCpt As Integer

        OpenFileDialog1.Filter = "Tiff Files|*.tif"

        OpenFileDialog1.ShowDialog()
        nImageID = AxImaging1.CreateImageFromFile(OpenFileDialog1.FileName)
        ImageList1.ImageSize = New Size(100, 100)
        ImageList1.Images.Clear()
        ListView1.Items.Clear()

        If nImageID <> 0 Then
            AxGdViewer1.ZoomMode = GdPicturePro5.ViewerZoomMode.ZoomFitToControl
            For nCpt = 1 To AxImaging1.TiffGetPageCount(nImageID)
                AxImaging1.TiffSelectPage(nImageID, nCpt)
                nThumbnailID = AxImaging1.CreateThumbnailHQ(nImageID, 100, 100)
                AxImaging1.SetNativeImage(nThumbnailID)
                Call ImageList1.Images.Add("", Bitmap.FromHbitmap(AxImaging1.GetHBitmap))
                Call ListView1.Items.Add("", nCpt - 1)
                AxImaging1.CloseImage(nThumbnailID)
            Next nCpt
            AxImaging1.TiffSelectPage(nImageID, 1)
            AxGdViewer1.SetNativeImage(nImageID)
        End If

        ListView1.LargeImageList = ImageList1
    End Sub

End Class

It is just a basic (but fast) way to get thumbnail images list from a multipage tiff file using the std vb.net objects.

I think we can get better result using GdViewer objects to show thumbnails...


Best regards,

Loïc Carrère
Attachments
screenshot.JPG
screenshot

shauns
Posts: 21
Joined: Fri May 25, 2007 3:43 pm
Location: North West England

Re: Thumbnails and .Net

Post by shauns » Mon Jan 14, 2008 11:58 am

Hi Loïc,

Thank you! This will do brilliantly.

regards

Shaun

NWM
Posts: 11
Joined: Wed Oct 17, 2007 8:09 pm

Re: Thumbnails and .Net

Post by NWM » Thu Mar 27, 2008 2:07 am

How would you modify this code to work with PDF files?

Thanks,

Neil

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Thumbnails and .Net

Post by Loïc » Fri Mar 28, 2008 1:38 pm

Hi Neil,

see this topic: https://www.gdpicture.com/livesupport/th ... -t564.html


Best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest