Gecko struggles with hi-res images intented for printing. Gecko chews up memory, makes for slow drawing, or even gives up on displaying the image altogether (worse on slow machines). This cache takes requests for images and returns lo-res versions of them.
Inheritance: IDisposable
Esempio n. 1
0
        protected override void Dispose(bool fDisposing)
        {
            //the container that gave us this will dispose of it: _cache.Dispose();
            _cache = null;

            base.Dispose(fDisposing);
        }
Esempio n. 2
0
        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
            }
        }
Esempio n. 3
0
        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);
                }
            }
        }
Esempio n. 7
0
 public ImageServer(LowResImageCache cache)
 {
     _cache    = cache;
     _useCache = Settings.Default.ImageHandler != "off";
 }
Esempio n. 8
0
 public ImageServer(LowResImageCache cache)
 {
     _cache = cache;
     _stop = new ManualResetEvent(false);
 }
Esempio n. 9
0
 public ImageServer(LowResImageCache cache)
 {
     _cache = cache;
     _stop  = new ManualResetEvent(false);
 }