Example #1
0
        public void GetSourceImageColorByCoordinate_Always_ReturnExpectedValue(int y, int x, int colorIndex)
        {
            var painter = new Painter(GetTestPatternImage(), GetTestSourceImage());
            var expectedColor = this.testColors[colorIndex];

            var result = painter.GetSourceColor(x, y);

            Assert.AreEqual(expectedColor, result);
        }
Example #2
0
        public void FillPixel_Always_FillExpectedPixelByExpectedColor(int y, int x, int colorIndex)
        {
            var painter = new Painter(GetTestPatternImage(), GetTestSourceImage());
            var expectedColor = this.testColors[colorIndex];

            painter.FillPixel(painter.FilledImage, x, y, expectedColor);

            Assert.IsTrue(IsPixelHasExpectedColor(painter.FilledImage, x, y, expectedColor));
        }
 protected override void Update()
 {
     if (Configuration.SelectedRegion != null)
     {
         this.currentRegion = Configuration.SelectedRegion;
         RegionColors = this.currentRegion.Colors;
         if (Colors == null)
         {
             Colors = new ObservableCollection<ColorViewModel>();
             UpColors = new ObservableCollection<ColorViewModel>();
             DownColors = new ObservableCollection<ColorViewModel>();
         }
         else
         {
             Colors.Clear();
             UpColors.Clear();
             DownColors.Clear();
         }//GetColors(this.currentRegion);
         SourceImage = Utilities.GetImageFromFile(this.currentRegion.SourceImageName);
         ResultSourceImage = new WriteableBitmap(SourceImage);
         OnPropertyChanged(nameof(SourceImage));
         PatternImage = new WriteableBitmap(SourceImage.Clone());
         OnPropertyChanged(nameof(PatternImage));
         OnPropertyChanged(nameof(RegionName));
         OnPropertyChanged(nameof(RegionDescription));
         this.patternImagePainter = new Painter(PatternImage, SourceImage);
         this.sourceImagePainter = new Painter(ResultSourceImage, SourceImage);
     }
 }
Example #4
0
 private void ResetPainter()
 {
     this.painter?.Dispose();
     if (PatternImage != null && SourceImage != null)
     {
         this.painter = new Painter(PatternImage, SourceImage);
     }
 }
 protected override void Update()
 {
     if (Configuration.SelectedRegion != null)
     {
         this.currentRegion = Configuration.SelectedRegion;
         Colors = GetColors();
         SourceImage = Utilities.GetImageFromFile(this.currentRegion.ThumbnailImageName);
         PatternImage = new WriteableBitmap(SourceImage.Clone());
         this.painter = new Painter(PatternImage, SourceImage.Clone());
     }
 }