PC Review


Reply
Thread Tools Rate Thread

Display .jpg thumbnails in ListView

 
 
Paul
Guest
Posts: n/a
 
      19th Mar 2005
Hi,

I'm struggling to create an app that contains a window showing thumbnails of
all. jpg files within a specified directory.
I've been a couple of examples of how to iterate through a directory and
extract thumbnails from each jpg file but nothing about what should happen
to the extracted thumbnail. Ideally I would like each thumbnail to be
displayed (with filename underneath each thumbnail) in a listview control
(large icon view).

I have a very old VB6 app that does this (by using an imagelist control to
hold the thumbnail info) but it's not the fastest app, doesn't compile in
..NET so ideally I'd like a VB.NET version.

Any help much appreciated

Cheers,
Paul


 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      19th Mar 2005
I know about the C# Thumbnail Extractor on vbaccelerator.com but I don't
know how to program in C# and the C# to VB.NET convertors produce tons of
errors.



"Paul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm struggling to create an app that contains a window showing thumbnails
> of all. jpg files within a specified directory.
> I've been a couple of examples of how to iterate through a directory and
> extract thumbnails from each jpg file but nothing about what should happen
> to the extracted thumbnail. Ideally I would like each thumbnail to be
> displayed (with filename underneath each thumbnail) in a listview control
> (large icon view).
>
> I have a very old VB6 app that does this (by using an imagelist control to
> hold the thumbnail info) but it's not the fastest app, doesn't compile in
> .NET so ideally I'd like a VB.NET version.
>
> Any help much appreciated
>
> Cheers,
> Paul
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      19th Mar 2005
"Paul" <(E-Mail Removed)> schrieb:
>I know about the C# Thumbnail Extractor on vbaccelerator.com but I don't
>know how to program in C# and the C# to VB.NET convertors produce tons of
>errors.


You may want to keep the implementation of the Thumbnail Extractor in C#,
build a class library and use this class library in your VB.NET project.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      19th Mar 2005
Thanks,
I still have the C# Project, how would I build a class library to use in my
VB.NET project?

Cheers,
Paul




"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Paul" <(E-Mail Removed)> schrieb:
>>I know about the C# Thumbnail Extractor on vbaccelerator.com but I don't
>>know how to program in C# and the C# to VB.NET convertors produce tons of
>>errors.

>
> You may want to keep the implementation of the Thumbnail Extractor in C#,
> build a class library and use this class library in your VB.NET project.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      19th Mar 2005
"Paul" <(E-Mail Removed)> schrieb:
> I still have the C# Project, how would I build a class library to use in
> my VB.NET project?


Add the C# project to the solution that contains the VB.NET project. Make
sure that the C# project is a class library project (the project type can be
changed in the project properties). Then you can add a project reference to
the C# project in your VB.NET project. To do this, select the project in
the solution explorer, choose "Add/Remove reference..." from its context
menu and select the C# project on the "Projects" tab.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      20th Mar 2005
Ok, i added the project to the solution and added the reference but on
second thought I think the C# Thumbnail Extractor is overkill for my needs.
I only need .jpg thumbs not excel and word ones, plus I can't for the life
of me figure out how to use the routines from the C# project in my VB.NET
project. Not smart enough!

I have however found new code which does pretty much what I want.
Pasted below for everyone's advantage.

Start with a blank form, add a listview control and imagelist control. One
thing I am stuck on is the thumbnails are 'stretched' to fit the dimensions
specified (120,120).
I need to keep within 120x120 but keep the aspect ratio intact, in other
words keep the proportions. The other task I need help with is ensuring
that when a thumbnail or multiple thumbnails are selected, then deleted,
that the listview is updated and refreshed preferably without rebuilding the
entire imagelist!

Any ideas?

Cheers,
Paul


CODE START

Const IMAGE_DIRECTORY As String = "INSERT PATH TO JPGs HERE"
Dim files As String() = Directory.GetFiles(IMAGE_DIRECTORY)
Dim max_length, i As Integer
Dim s, fname As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ImageList_Load()
ListView_Load()
'Me.Controls.AddRange(New Control() {listView1})
End Sub

Private Sub ImageList_Load()
Dim pname As String
Dim myImage As Image
'Set the ColorDepth and ImageSize properties of imageList1.
imageList1.ColorDepth = ColorDepth.Depth32Bit
imageList1.ImageSize = New System.Drawing.Size(120, 120)
max_length = files.Length - 2
'Add images to imageList1.
For i = 0 To max_length
pname = Path.GetFullPath(files(i))
myImage = Image.FromFile(pname)
imageList1.Images.Add(myImage)
myImage = Nothing
Next
pname = Nothing
End Sub

Private Sub ListView_Load()
'ListView1.View = View.LargeIcon
ListView1.LargeImageList = imageList1
For i = 0 To files.Length - 2
fname = Path.GetFileName(files(i))
Dim listViewItem1 As ListViewItem = New ListViewItem(fname, i)
'Add listViewItem1 and listViewItem2.
ListView1.Items.AddRange(New ListViewItem() {listViewItem1})
listViewItem1 = Nothing
Next
End Sub



CODE END



"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Paul" <(E-Mail Removed)> schrieb:
>> I still have the C# Project, how would I build a class library to use in
>> my VB.NET project?

>
> Add the C# project to the solution that contains the VB.NET project. Make
> sure that the C# project is a class library project (the project type can
> be changed in the project properties). Then you can add a project
> reference to the C# project in your VB.NET project. To do this, select
> the project in the solution explorer, choose "Add/Remove reference..."
> from its context menu and select the C# project on the "Projects" tab.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows-Like thumbnails in ListView? Vagabond Software Microsoft C# .NET 4 21st Feb 2011 11:25 AM
virtual listview with thumbnails Def Daemon Microsoft C# .NET 3 17th Mar 2010 02:52 PM
ListView - Caching Thumbnails? Dale Atkin Microsoft VB .NET 6 28th May 2009 11:52 PM
ListView - Caching Thumbnails? Dale Atkin Microsoft VB .NET 0 26th May 2009 08:26 PM
Virtual Listview with Thumbnails P.J.M. Beker Microsoft Dot NET Framework Forms 0 3rd Apr 2009 10:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 PM.