Notifications
Clear all

[Closed] Thumbnail viewer control

The problem with the external image libraries that can load things like TGA and DDS is that they are usually 32 bit. There is a 64bit version of imagemagik and I have seen unofficial builds of freeimage, but in the end I used the clipboard swaperoo method in Hithchiker. With transparent TGAs I normally convert them to PNG for display purposes.

in HH, Image formats that windows natively opens, like JPG, PNG and TIF are generated as part of a threaded GDI+ process within the control. These are subsequently fast to return, and keeps the UI thread of max separate. Non-windows formats are opened in 3dsmax by registering a bitmap loading function with the MaxScriptSDK methods in the managedservices.dll. The 3dsmax bitmap is then passed back to the control via the clipboard as a DotNet bitmap where they are processed in a non threaded environment. The thumbnailing routine is still performed in the assembly rather than Max as by this point the bitmap is in the correct bitmap format for the control to use. You are simply using the 3dsMax Image readers to plug the gap in DotNet file types.This is all made possible via the enhancements to the managedservices.dll. I thread the dotnet compatible formats but still use the assembly to perform the image resize.

The other speed boost I introduced was to have a cachemode property, this pools the thumbnails locally – meaning it only looks for new files to resize. That way, after the first load delay, the display pops up immediately the next time. When you have folders that people are visiting repeatedly, it works like a charm. I can imagine that 1000 tgas would take a while to load! Hitchhiker operates on folders with a few hundred.

Could you elaborate on the memory leak you see between clipboard>.net denis? I was always careful to monitor the ram usage in HH and i didnt see anything untoward in the thumbnailing method.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

there is no leaking on clipboard -> .net. there is a leaking on creating any max bitmap. maybe i’m missing something but reading TGA or DDS in max you open bitmap using maxscript, and put this bitmap in clipboard. right? that’s a bottleneck.

Yeah… I’ve been worried about that issue… loading too many TGAS and crashing max.

I run the GC() and ReleaseBitmaps to try and help/hope it helps. I also make sure to close each bitmap after I open it. So far so good… I’ve had my tool displaying like 40 .tga files at once, fairly quickly without issue, while displaying those bitmaps in viewport as well. Although since some are the same bitmap, its not as bad I guess.

I can’t keep a cache or don’t for mine, since I use it for Game Dev and I constant am looking at different assets to see what bitmaps are applied. So my tool extracts all bitmaps it finds in the material of an object, and quickly gives me the info. I need without having to search through the materials.

If I cached stuff for my tool personally, I would have many more max crashes I’m sure :P. Especially since we use DX materials at work, which are already unstable in max sometimes. Also our scenes take up alot of ram sometimes, and my machine only has 4GB :(.

http://www.jasonlabbe3d.com/pages/thumbnailViewerControl.html

I updated the control with the feed back I got from a few of you. There’s an event that triggers whenever you right-click an item, a new property where you can set text for an item’s tool tip, and tried to fix a bug for Mac so it doesn’t accept hidden files. I also added an option to enable little exit buttons on the items as it’s something I needed for myself. All of these features are demonstrated in a sample .ms file that comes with the new assembly.

I started on the multi-select feature and I’m hoping to have it up in a few days. Enjoy!

awesome, thank you so much! rclick was exactly what i needed.

Are you sure? How about MBUTTON, XBUTTON1, and XBUTTON2 clicks?

lol, let’s not get crazy.

The control has been updated to support multi-selection! Hold ctrl down to select more than one item. There’s a property called .selectedItems that will return a list of the current selected thumbnail items. Each thumbnailItem .net object has a .isSelected() method that you can also use. Get the update here:
http://www.jasonlabbe3d.com/pages/thumbnailViewerControl.html

whoa, denis is a genius. what if we could hook up xbox controllers to the dotnet control? can you add rtrigger and ltrigger? that way we could make all kinds of pointless-yet-kind-of-cool features that no one would ever use!

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that’s exactly what I’m talking about. It should be only one mouse click event, and it has to return Button argument.

Awesome dude! I will check it out here sometime soon :). I may end up switching to your setup instead of what I have now then

first of all, it’s a very cute control. but there are some things those make the control a bit heavy:

  1. remove button (add method to remove selected)
  2. rightclick (add mouseclick or itemclick event with button argument)
  3. get/set color by methods (use a property)
  4. any other get/set methods where is easier to use property.

all is IMHO.

only thing that I want to say. .NET is the world with its own rules. Rules can be wrong but they are the rules. Using any dotnet control at the first time I’m sure that I know 90% of its properties, methods, and events. When I can’t find the MouseDoulbeClick event for example, I say “What’s the f*k?!”

  1. I’ve got 2 methods to remove an item by index or clear all items. There’s also a button that can be enabled on the actual thumbnail item for the user to hit (though the coder needs to add script in that event). Am I missing something?

  2. Agreed.

3 and 4. I’m still learning the language and did it this way because of my lack of knowledge. I set them up as methods so I could physically change the control’s color or whatever. I should have digged more into this but maybe you can explain how one could ‘wire’ a property so when it changes it would actually trigger the color on the control to change.

Yes good point, I agree about the rules of .net and consistency, something I’ll have to keep in mind next time.

first of all, it’s a very cute control.

I’m sure it’s not at all intentional, but that sounds insulting like you look down on it. Please be a little more considerate.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

no,no,no… sorry if i wronged you any way. saying CUTE i meant ELEGANT. i’m really like the control. i saw the code and the code is very clean but i wish the control be better.
Probably it’s my nature to desire everything perfect. sorry again for any inconsiderate remarks.

Page 4 / 5