|brian on Oct 13, 2010 at 1:13:10 AM (# 7)|
Yeah, fullSizeImage.GetThumbnailImage doesn't handle exif correctly on some versions of Windows...they have an embedded thumbnail which later versions seem to use
what to do is change fullSizeImage.GetThumbnailImage with the following:
thumbnailImage=new Bitmap(resizedWidth, resizedHeight)
gfx.DrawImage(fullSizeImage,new Rectangle(0,0,resizedWidth, resizedHeight));
it should do exactly the same thing but actually gives you a better image because of interpolation settings and also should work properly with exif.
Monte on Oct 13, 2010 at 4:26:56 AM (# 8)
Thanks! I'll give that a shot, and let you know what happens! Might be a few days, though.
Monte on Oct 18, 2010 at 7:30:03 PM (# 9)
Ok. I made the changes, and it seems to work on my XP box. I'll have to send the app to the guy who needs it and see what he says. Thanks for all the help.
brian on Oct 19, 2010 at 2:14:41 AM (# 10)
Glad to be of help. Took me a while to figure that out and I think generally it produces better images, especially when coupled with the compression code as well for jpegs.
Let me know if this works.
Monte on Oct 19, 2010 at 8:20:43 AM (# 11)
Is it faster than the approach I took, as well? I mean from an execution standpoint.
In other words, if I had two directories with 100 identical photos, and I ran this app with the "old" code vs the "new" code, would it execute faster?
What about Memory? I was having a problem with memory overruns (yet it would still resize...).
brian on Oct 19, 2010 at 9:34:08 AM (# 12)
I couldn't say if it was faster and I've experienced memory issues too with large images but I'm doing it from a web server so generally you have about 1/2gb to work with.
The key with this is after every image is finished with do an image.Dispose() to clean up as well as on the resized bitmaps and their corresponding Graphics. You could also try doing a gc.collect after, say, every 5 images. This will impact slightly on speed but should help release resources no longer needed. so, after the thumbnailImage.Save do
add an int counter=0; at the top and add after the dispose something like
if ((++counter)%5==0) gc.Collect();
The modulus is handy because you don't have to reset the counter when you hit 5.
You could easily spread this out over a few lines for maintainability as it makes no difference really.
Try without gc first as disposing will release and allow memory to be reused which is probably what the issue was before as reassigning a variable or nulling them takes a little longer than doing an explicit dispose. Also you'd probably find that files are locked until the application exits because they are technically still in use by the image.
AnnieCalvert on Jul 15, 2012 at 10:42:03 PM (# 13)
The method of data presentation depends on the number of headers in the grid. Upon display of each row the grid searches for a header for it, and if it doesn't find it, a header from the previous hierarchy level is used. This enables to implement the grid and tree list view in a single component.