|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ListView - Caching Thumbnails?I'm using the listview control to display thumbnails for a number of
relatively large images (~4MB each). I was thinking, it would speed things up if I could cache a thumbnail for each image, and display that, rather than the actual image. I'm not really totally sure how to do that... I've been looking in to the Image.GetThumbNailImage function, but it doesn't seem to be working as expected. If I use this, does the main image still get loaded if a cached thumbnail exists? Is there a better way of doing this? It seems to be running quite slowly, and I'm not sure why. Dale Hi Dale,
> I'm using the listview control to display thumbnails for a number of Basically what you would want to do is create a Dictionary...> relatively large images (~4MB each). > > I was thinking, it would speed things up if I could cache a thumbnail for > each image, and display that, rather than the actual image. I'm not really > totally sure how to do that... Dim myimagecache as new Dictionary(Of String, Bitmap) myimagecache .Add(filename, bitmapobject) << Adding myimagecache .Item(filename) << Retreiving > I've been looking in to the Image.GetThumbNailImage function, but it To be honest I wouldn't use this feature, not only is it slow but it can > doesn't seem to be working as expected. also return embedded thumbnails in images which don't always match the actual image. Also the quality returned isn't as great as it can be. > If I use this, does the main image still get loaded if a cached thumbnail Yup, you need to perform any caching yourself. One thing to remember > exists? though is when you want to remove images from your cache, dispose of them first.... Dim myimage as Bitmap = myimagecache .Item(filename) myimagecache.Remove(filename) Call myimage.Dispose() Of course if you are clearing the entire cache you will need to do this for each individual bitmap. It won't take long but will make sure your app runs smoothly and you don't run out of resources. > Is there a better way of doing this? One thing I have done in the past to get lightning fast thumbnails was to use this, http://www.vbaccelerator.com/home/net/code/libraries/shell_projects/Thumbnail_Extraction/article.asp It's a hell of allot faster than using GetThumbnailImage or even creating the thumbnail yourself. Nick. >> Is there a better way of doing this? This looks very interesting, and should suit my needs. I'll have to take a > > One thing I have done in the past to get lightning fast thumbnails was > to use this, > > > http://www.vbaccelerator.com/home/net/code/libraries/shell_projects/Thumbnail_Extraction/article.asp > > It's a hell of allot faster than using GetThumbnailImage or even > creating the thumbnail yourself. closer look at it. Do you happen know off the top of your head if it is relying on the file extension to determine the file type? Or does it look at the actual file? One thing I've done, to try to discourage novice users from monkeying with the underlying data outside my program, is to strip off the file extensions. Looking at how this is working would tend to make me believe that the file extensions might be important for this to work properly. Dale Hi Dale,
Umm, well as it's using Explorer, my understanding is that the file extension will play a big part. The best thing to do would be to have a try tbh, but I think if Explorer treats the image differently after changing the extension then so will this method. Out of interest are you thumbnailing images that are packed with the application, or images that are created by the application at runtime? If the latter, one thing you could do, is create an index file that holds the file type of each file and then just associate it by a key of some kind. <CacheIndex> <CacheItem> <Key>key goes in here</Key> <OriginalType>original file extension goes in here</OriginalType> <MD5Hash>hash of file data goes in here</MD5Hash> </CacheItem> <CacheItem> <Key>key goes in here</Key> <OriginalType>original file extension goes in here</OriginalType> <MD5Hash>hash of file data goes in here</MD5Hash> </CacheItem> ... </CacheIndex> I wrote "MD5Hash" there too as if you don't want the user to change the files in any way, you could also hash them and compare the hash with the actual file data upon retrieval, if it differs then you know it's been tampered with. Nick. Show quoteHide quote "Dale Atkin" <labrad***@ibycus.com> wrote in message news:eu1gKK#3JHA.5204@TK2MSFTNGP02.phx.gbl... > >>> Is there a better way of doing this? >> >> One thing I have done in the past to get lightning fast thumbnails was >> to use this, >> >> >> http://www.vbaccelerator.com/home/net/code/libraries/shell_projects/Thumbnail_Extraction/article.asp >> >> It's a hell of allot faster than using GetThumbnailImage or even >> creating the thumbnail yourself. > > This looks very interesting, and should suit my needs. I'll have to take a > closer look at it. > > Do you happen know off the top of your head if it is relying on the file > extension to determine the file type? Or does it look at the actual file? > One thing I've done, to try to discourage novice users from monkeying with > the underlying data outside my program, is to strip off the file > extensions. Looking at how this is working would tend to make me believe > that the file extensions might be important for this to work properly. > > Dale > "nak" <a@a.com> wrote in message That was my thought too. I'm in the midst of some restructuring right now news:E73ABDDB-A536-4A99-B86A-A0551B37EC02@microsoft.com... > Hi Dale, > > Umm, well as it's using Explorer, my understanding is that the file > extension will play a big part. The best thing to do would be to have a > try tbh, but I think if Explorer treats the image differently after > changing the extension then so will this method. though (see my other question on looking for an XML tutorial for details), so I may put the extension back in. It isn't really *crucial* that the user doesn't change the files. The program just will yield some odd results if they do (which I figure they can deal with if they are monkeying with the database ;). > Out of interest are you thumbnailing images that are packed with the Basically they are images that the user imports in to an internal database. > application, or images that are created by the application at runtime? If > the latter, one thing you could do, is create an index file that holds the > file type of each file and then just associate it by a key of some kind. The underlying goal here is to create an interactive anatomical atlas program using high resolution images. Basically, it is a tool to help students learn/study anatomy. The user (or the prof) brings in an image, tags it with certain attributes (i.e. this is x,y,z). The images then become 'clickable' and will bring up a description of what ever you clicked on. The description is then also clickable, and contains links to related topics, and images within the database (this is where the thumbnails come in... in the search box, the user is presented with thumbnails of the 'hits'). Dale Hi Dale
> That was my thought too. I'm in the midst of some restructuring right now Here's one I wrote a while back, a little dated now as it was written > though (see my other question on looking for an XML tutorial for details), > so I may put the extension back in. It isn't really *crucial* that the > user doesn't change the files. The program just will yield some odd > results if they do (which I figure they can deal with if they are > monkeying with the database ;). for .net 1.0, but it should still work, http://www.npsoftware.co.uk/Tutorials/tut_data_persistence_XML.php Personally I don't use databases unless I really need to, I think they are overused and not everyone wants SQL Server installed, even if it is an Express edition. Access databases fill the middle ground I guess but still, you can edit XML by hand. > Basically they are images that the user imports in to an internal Aaah okay, then there is allot to think about in that respect, as I'm > database. The underlying goal here is to create an interactive anatomical > atlas program using high resolution images. Basically, it is a tool to > help students learn/study anatomy. The user (or the prof) brings in an > image, tags it with certain attributes (i.e. this is x,y,z). The images > then become 'clickable' and will bring up a description of what ever you > clicked on. The description is then also clickable, and contains links to > related topics, and images within the database (this is where the > thumbnails come in... in the search box, the user is presented with > thumbnails of the 'hits'). not entirely how your app will be setup. Like how is the application going to be accessed? Client based instancing or a Web Browser? What data exactly is going to be shared? If it's per user instancing then you have no need to use SQL, you can even encrypt and base 64 XML nodes so the user won't be able to read them without a bit of "hacking" anyway. If you want to share the thumbnails and indexing file through a web browser then you could get away with creating a web service that incorporates a singleton instance of your indexing reader/writer, but that is a little more work than just using a database in that respect. Decisions eh? lol! Good luck anyway! Nick.
Show quote
Hide quote
"nak" <a@a.com> wrote in message I'm throwing around the term 'database' a bit too liberally here. Basically news:3B5A014D-6C62-4403-8BB4-4DC8852E5912@microsoft.com... > Hi Dale > >> That was my thought too. I'm in the midst of some restructuring right now >> though (see my other question on looking for an XML tutorial for >> details), so I may put the extension back in. It isn't really *crucial* >> that the user doesn't change the files. The program just will yield some >> odd results if they do (which I figure they can deal with if they are >> monkeying with the database ;). > > Here's one I wrote a while back, a little dated now as it was written > for .net 1.0, but it should still work, > > http://www.npsoftware.co.uk/Tutorials/tut_data_persistence_XML.php > > Personally I don't use databases unless I really need to, I think they > are overused and not everyone wants SQL Server installed, even if it is an > Express edition. Access databases fill the middle ground I guess but > still, you can edit XML by hand. I'm building up a collection of XML files, and image files (JPGs), that will be stored in a data directory. I tend to stay away from more 'formal' databases as well (unless I have a really strong call for it). I've been working with Chris's example (dunawayc), and having a lot of success with it. Only problem, is I have to do a lot of backend restructuring, but in the end I think its worth it. Show quoteHide quote > I'm going 'old school' on it. I despise webbased apps for this kind of >> Basically they are images that the user imports in to an internal >> database. The underlying goal here is to create an interactive anatomical >> atlas program using high resolution images. Basically, it is a tool to >> help students learn/study anatomy. The user (or the prof) brings in an >> image, tags it with certain attributes (i.e. this is x,y,z). The images >> then become 'clickable' and will bring up a description of what ever you >> clicked on. The description is then also clickable, and contains links to >> related topics, and images within the database (this is where the >> thumbnails come in... in the search box, the user is presented with >> thumbnails of the 'hits'). > > Aaah okay, then there is allot to think about in that respect, as I'm > not entirely how your app will be setup. Like how is the application > going to be accessed? Client based instancing or a Web Browser? What data > exactly is going to be shared? thing. The images are too big to deliver efficiently (the ones I'm working at the moment with total more than 10GB...), so most people end of scaling the images down. Trying to learn, this can be *really* frustrating, as you'll be looking at the file, and you just want to zoom in 'a little bit' but you're stuck, and you know the original image was higher resolution, but they cut it back to make the CD/DVD etc. You also then have to worry a lot more about security/access rights if the database is shared between users. So, yeah, the whole thing is going to be released on a DVD, and the user can do what the heck they like with it. I've pretty well decided now that if the user messes with the back end stuff, then it serves them right if the program crashes on them. (they'll just have to delete the files they changed to get it to work again.). > Decisions eh? lol! Good luck anyway! Lots of fun. Luckily I have the next 3 months to get it all working as I want it to. Then I go back to school (and next year's class gets to play with my program and find all the bugs in it ;) ). Dale
System.IO.File.Copy + NTFS Streams + special ACLs
save treeview state and call from another form Help with Event handler, withevents, raise events Bitmap from a file System icons in Listview VS2010 for database developers How to catch page redirect windows mobile pocketoutlook disabling MdiParent during load causes incorrect MdiChild to be ac ISAM not found |
|||||||||||||||||||||||