示例#1
0
        protected void SetItemThumbnail(ImageBuffer thumbnail)
        {
            if (thumbnail != null)
            {
                // Resize canvas to target as fallback
                if (thumbnail.Width < thumbWidth || thumbnail.Height < thumbHeight)
                {
                    thumbnail = ListView.ResizeCanvas(thumbnail, thumbWidth, thumbHeight);
                }
                else if (thumbnail.Width > thumbWidth || thumbnail.Height > thumbHeight)
                {
                    thumbnail = LibraryProviderHelpers.ResizeImage(thumbnail, thumbWidth, thumbHeight);
                }

                if (GuiWidget.DeviceScale != 1)
                {
                    thumbnail = thumbnail.CreateScaledImage(GuiWidget.DeviceScale);
                }

                // TODO: Resolve and implement
                // Allow the container to draw an overlay - use signal interface or add method to interface?
                //var iconWithOverlay = ActiveContainer.DrawOverlay()

                if (thumbnail != null &&
                    this.imageWidget != null &&
                    (this.imageWidget.Image == null ||
                     !thumbnail.Equals(this.imageWidget.Image, 5)))
                {
                    this.imageWidget.Image = thumbnail;
                    this.ImageSet?.Invoke(this, null);
                    this.Invalidate();
                }
            }
        }
示例#2
0
 private void SetSizedThumbnail(ImageBuffer thumbnail)
 {
     if (thumbnail != null &&
         this.imageWidget != null &&
         (this.imageWidget.Image == null ||
          !thumbnail.Equals(this.imageWidget.Image, 5)))
     {
         this.imageWidget.Image = thumbnail;
         this.Invalidate();
     }
 }
示例#3
0
        private void CheckTestAgainstControl(ImageBuffer testImage, string testTypeString)
        {
            Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);

            // there is an assumption that we got to save valid images at least once.
            string      controlFileTga          = testTypeString + " Control.tga";
            string      imageFolder             = "ControlImages";
            string      testFailPathAndFileName = Path.Combine(imageFolder, testTypeString + " Test Fail.tga");
            ImageBuffer controlImage            = new ImageBuffer();

            if (!Directory.Exists(imageFolder))
            {
                Directory.CreateDirectory(imageFolder);
            }
            string controlPathAndFileName = Path.Combine(imageFolder, controlFileTga);

            if (File.Exists(controlPathAndFileName))
            {
                ImageTgaIO.LoadImageData(controlImage, controlPathAndFileName);

                bool testIsSameAsControl = controlImage.Equals(testImage);
                if (!testIsSameAsControl)
                {
                    // this image will be in the current output folder inside of imageFolder
                    ImageTgaIO.Save(testImage, testFailPathAndFileName);
                }
                else if (File.Exists(testFailPathAndFileName))
                {
                    // we don't want to have these confounding our results.
                    File.Delete(testFailPathAndFileName);
                }

                Assert.IsTrue(testIsSameAsControl);
                // If you want to create new control images select SetNextStatement to inside the else condition to create them.
            }
            else
            {
                ImageTgaIO.Save(testImage, controlPathAndFileName);
            }
        }