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
コード例 #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);
        }
コード例 #2
0
ファイル: ImageServer.cs プロジェクト: JohnThomson/testBloom
        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
            }
        }
コード例 #3
0
ファイル: ImageServer.cs プロジェクト: ermshiperete/testBloom
        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
            }
        }
コード例 #4
0
 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);
         }
     }
 }
コード例 #5
0
 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);
         }
     }
 }
コード例 #6
0
        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);
                }
            }
        }
コード例 #7
0
 public ImageServer(LowResImageCache cache)
 {
     _cache    = cache;
     _useCache = Settings.Default.ImageHandler != "off";
 }
コード例 #8
0
ファイル: ImageServer.cs プロジェクト: JohnThomson/testBloom
 public ImageServer(LowResImageCache cache)
 {
     _cache = cache;
     _stop = new ManualResetEvent(false);
 }
コード例 #9
0
ファイル: ImageServer.cs プロジェクト: ermshiperete/testBloom
 public ImageServer(LowResImageCache cache)
 {
     _cache = cache;
     _stop  = new ManualResetEvent(false);
 }