A simple c# image resizer with ScaleToFit and ScaleToFill using wpf libraries. Resizes to jpg, gif, png, tiff. Demosite is hosted at AppHarbor: http://imageresizer.apphb.com/
58
stars
27
forks
source link
The mysterious exception "operation completed successfully"... #9
private byte[] TransformImage(byte[] image, int width) {
if (width <= 0)
return image;
ImageEncoding imgEncoding = ImageEncoding.Jpg;
ImageResizer resizer = new ImageResizer(image);
if (width > 1000) {
imgEncoding = ImageEncoding.Jpg100;
}
return resizer.Resize(width, width, false, imgEncoding);
}
The strange exception:
Type: System.ComponentModel.Win32Exception
Message: The operation completed successfully
:eyes:
Stack trace (partial):
System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
at System.Windows.DependencyObject..ctor()
at System.Windows.Media.Imaging.BitmapSource..ctor(Boolean useVirtuals)
at Simple.ImageResizer.ImageResizer.LoadBitmapImage(Byte[] bytes)
But... as the message suggests, the image is rendered properly.
Anyone have any idea of what's going on? Why this error is being throwed?
This error is only thrown in my production webserver (Azure). Locally it doesn't happen.
I've searched and apparently this error is related to not disposing properly Bitmap classes. I've tried to dispose the ImageResizer object, but it didn't make any effect. Would it be a bug in the ImageResizer component? (not cleaning up something?)
My code:
The strange exception:
Type: System.ComponentModel.Win32Exception Message: The operation completed successfully
:eyes:
Stack trace (partial):
But... as the message suggests, the image is rendered properly.
Anyone have any idea of what's going on? Why this error is being throwed?
Tks!