protected override void Dispose(bool fDisposing) { //the container that gave us this will dispose of it: _cache.Dispose(); _cache = null; base.Dispose(fDisposing); }
public void Dispose() { try { _isDisposing = true; //the container that gave us this will dispose of it: _cache.Dispose(); _cache = null; if (_listener != null) { //prompted by the mysterious BL 273, Crash while closing down the imageserver Guard.AgainstNull(_listenerThread, "_listenerThread"); //prompted by the mysterious BL 273, Crash while closing down the imageserver Guard.AgainstNull(_stop, "_stop"); _stop.Set(); _listenerThread.Join(); _listener.Stop(); _listener.Close(); } _listener = null; } catch (Exception e) { //prompted by the mysterious BL 273, Crash while closing down the imageserver #if DEBUG throw; #else //just quitely report this DesktopAnalytics.Analytics.ReportException(e); #endif } }
public void Dispose() { try { _isDisposing = true; //the container that gave us this will dispose of it: _cache.Dispose(); _cache = null; if (_listener != null) { //prompted by the mysterious BL 273, Crash while closing down the imageserver Guard.AgainstNull(_listenerThread, "_listenerThread"); //prompted by the mysterious BL 273, Crash while closing down the imageserver Guard.AgainstNull(_stop, "_stop"); _stop.Set(); _listenerThread.Join(); _listener.Stop(); _listener.Close(); } _listener = null; } catch (Exception e) { //prompted by the mysterious BL 273, Crash while closing down the imageserver #if DEBUG throw; #else //just quitely report this DesktopAnalytics.Analytics.ReportException(e); #endif } }
public void GetTinyImage_DoesNotChangeSize() { using (var cache = new LowResImageCache(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempPNGImage(10,10)) { using (var img = Image.FromFile(cache.GetPathToResizedImage(file.Path))) { Assert.AreEqual(10, img.Width); } } }
public void GetWideImage_ReturnsShrunkImageWithCorrectProportions() { using (var cache = new LowResImageCache(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempPNGImage(200,80)) { using(var img = Image.FromFile(cache.GetPathToResizedImage(file.Path))) { Assert.AreEqual(100, img.Width); Assert.AreEqual(40, img.Height); } } }
public void GetJPG_ReturnsShrunkJPG() { using (var cache = new LowResImageCache(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempJPGImage(200, 80)) { var pathToResizedImage = cache.GetPathToResizedImage(file.Path); using (var img = Image.FromFile(pathToResizedImage)) { Assert.AreEqual(".jpg", Path.GetExtension(pathToResizedImage)); //TODO: why does this always report PNG format? Checks by hand of the file show it as jpg //Assert.AreEqual(ImageFormat.Jpeg.Guid, img.RawFormat.Guid); Assert.AreEqual(100, img.Width); Assert.AreEqual(40, img.Height); } } }
public ImageServer(LowResImageCache cache) { _cache = cache; _useCache = Settings.Default.ImageHandler != "off"; }
public ImageServer(LowResImageCache cache) { _cache = cache; _stop = new ManualResetEvent(false); }
public ImageServer(LowResImageCache cache) { _cache = cache; _stop = new ManualResetEvent(false); }