private ObservableCollection <VideoEffectsViewModel> CreateEditableEffects() { var effects = new ObservableCollection <VideoEffectsViewModel>(); m_contrastEffect = new ContrastEffect(); effects.Add(new VideoEffectsViewModel(m_contrastEffect, "contrast.png") { Name = "Contrast", MaxValue = 1.0, MinValue = -1.0 }); m_hueSaturationEffect = new HueSaturationEffect(m_contrastEffect); effects.Add(new VideoEffectsViewModel(m_hueSaturationEffect, "saturation.png") { Name = "Hue", MaxValue = 1.0, MinValue = -1.0, PropertyName = "Hue" }); effects.Add(new VideoEffectsViewModel(m_hueSaturationEffect, "saturation.png") { Name = "Saturation", MaxValue = 1.0, MinValue = -1.0, PropertyName = "Saturation" }); m_brightnessEffect = new BrightnessEffect(m_hueSaturationEffect); effects.Add(new VideoEffectsViewModel(m_brightnessEffect, "brightness.png") { Name = "Brightness", MaxValue = 1.0, MinValue = -1.0 }); return(effects); }
public void Constructor_InitializesExpectedProperties() { // Act var effect = new BrightnessEffect(0.5d); // Assert Assert.Equal(0.5d, effect.Brightness); }
private static ICanvasImage CreateBrighterEffect(ICanvasImage canvasImage) { var ef = new BrightnessEffect { Source = canvasImage, BlackPoint = new System.Numerics.Vector2(0.01f, 0.2f), WhitePoint = new System.Numerics.Vector2(0.85f, 0.95f) }; return(ef); }
async Task Canvas_CreateResourcesAsync(CanvasControl sender) { bitmap = await CanvasBitmap.LoadAsync(sender, "imageTiger.jpg"); redBrush = CreateGradientBrush(sender, 255, 0, 0); greenBrush = CreateGradientBrush(sender, 0, 255, 0); blueBrush = CreateGradientBrush(sender, 0, 0, 255); brightnessEffect = new BrightnessEffect { Source = bitmap }; saturationEffect = new SaturationEffect { Source = brightnessEffect }; hueEffect = new HueRotationEffect { Source = saturationEffect }; }
public void ISerializable_SerializeAndDeserializeCorrectly() { // Arrange var expected = new BrightnessEffect(0.5d); var info = MockSerializationInfo <BrightnessEffect>(); // Act expected.GetObjectData(info, new StreamingContext()); var actual = new BrightnessEffect(info, new StreamingContext()); // Assert Assert.Equal(expected.Brightness, actual.Brightness); }
public MainPage() { InitializeComponent(); double scaleFactor = 1.0; scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; _writeableBitmap = new WriteableBitmap((int)(Window.Current.Bounds.Width * scaleFactor), (int)(Window.Current.Bounds.Height * scaleFactor)); _thumbnailImageBitmap = new WriteableBitmap((int)OriginalImage.Width, (int)OriginalImage.Height); _grayscaleEffect = new GrayscaleEffect(); _brightnessEffect = new BrightnessEffect(_grayscaleEffect); SwapChainPanelTarget.Loaded += SwapChainPanelTarget_Loaded; }
async Task <Uri> Brightness(int EffectPercentage) { using (var source = new StorageFileImageSource(imageStorageFile)) using (var contrastEffect = new ContrastEffect(source) { Level = 0.6 }) using (var sharpnessEffect = new BrightnessEffect(contrastEffect) { Level = (EffectPercentage / 100) }) { LastEffect = sharpnessEffect; return(await SaveToImage()); } }
/// <summary> /// Applies the effect. /// </summary> /// <returns> /// An array of strings of the effect properties to change. /// </returns> public override string[] ApplyEffect() { var brightnessEffect = new BrightnessEffect { Name = EffectName, Source = new CompositionEffectSourceParameter("source") }; var propertyToChange = $"{EffectName}.WhitePoint"; var propertiesToAnimate = new[] { propertyToChange }; EffectBrush = Compositor.CreateEffectFactory(brightnessEffect, propertiesToAnimate).CreateBrush(); EffectBrush.SetSourceParameter("source", Compositor.CreateBackdropBrush()); return(propertiesToAnimate); }
private ICanvasImage CreateBrightness() { var brightnessEffect = new BrightnessEffect { Source = bitmapTiger }; // Animate the effect by changing parameters using sine waves of different frequencies. animationFunction = elapsedTime => { brightnessEffect.BlackPoint = new Vector2(((float)Math.Sin(elapsedTime * 0.7) + 1) / 5, ((float)Math.Sin(elapsedTime * 1.1) + 1) / 5); brightnessEffect.WhitePoint = new Vector2(1 - ((float)Math.Sin(elapsedTime * 1.3) + 1) / 5, 1 - ((float)Math.Sin(elapsedTime * 1.7) + 1) / 5); }; return(brightnessEffect); }
public void Calculate_AppliesEffectOnHeightMap(double brightness) { // Arrange var data = new double[, ] { { 0d, 0.25d, 0.5d, 0.75d, 1d } }; var heightMap = new HeightMap(data); var expected = MockImageEffect(heightMap, brightness); var effect = new BrightnessEffect(brightness); // Act var actual = effect.Calculate(heightMap).Data; // Assert Assert.Equal(expected[0, 0], actual[0, 0]); Assert.Equal(expected[0, 1], actual[0, 1]); Assert.Equal(expected[0, 2], actual[0, 2]); Assert.Equal(expected[0, 3], actual[0, 3]); Assert.Equal(expected[0, 4], actual[0, 4]); }
protected override void OnAssociatedObjectLoaded() { base.OnAssociatedObjectLoaded(); var visual = ElementCompositionPreview.GetElementVisual(AssociatedObject); var compositor = visual.Compositor; var brightnessEffect = new BrightnessEffect { Name = "BrightnessEffect", Source = new CompositionEffectSourceParameter("source") }; var effectFactory = compositor.CreateEffectFactory(brightnessEffect, new[] { "BrightnessEffect.WhitePoint" }); _brush = effectFactory.CreateBrush(); _brush.SetSourceParameter("source", compositor.CreateBackdropBrush()); //_brush.Properties.InsertScalar("BrightnessEffect.WhitePoint", 0f); }
private ICanvasImage CreateBrightness() { var brightnessEffect = new BrightnessEffect { Source = bitmapTiger }; // Animate the effect by changing parameters using sine waves of different frequencies. animationFunction = elapsedTime => { brightnessEffect.BlackPoint = new Vector2(((float)Math.Sin(elapsedTime * 0.7) + 1) / 5, ((float)Math.Sin(elapsedTime * 1.1) + 1) / 5); brightnessEffect.WhitePoint = new Vector2(1 - ((float)Math.Sin(elapsedTime * 1.3) + 1) / 5, 1 - ((float)Math.Sin(elapsedTime * 1.7) + 1) / 5); }; return brightnessEffect; }
private ObservableCollection<VideoEffectsViewModel> CreateEditableEffects() { var effects = new ObservableCollection<VideoEffectsViewModel>(); m_contrastEffect = new ContrastEffect(); effects.Add(new VideoEffectsViewModel(m_contrastEffect, "contrast.png") { Name = "Contrast", MaxValue = 1.0, MinValue = -1.0 }); m_hueSaturationEffect = new HueSaturationEffect(m_contrastEffect); effects.Add(new VideoEffectsViewModel(m_hueSaturationEffect, "saturation.png") { Name = "Hue", MaxValue = 1.0, MinValue = -1.0, PropertyName = "Hue" }); effects.Add(new VideoEffectsViewModel(m_hueSaturationEffect, "saturation.png") { Name = "Saturation", MaxValue = 1.0, MinValue = -1.0, PropertyName = "Saturation" }); m_brightnessEffect = new BrightnessEffect(m_hueSaturationEffect); effects.Add(new VideoEffectsViewModel(m_brightnessEffect, "brightness.png") { Name = "Brightness", MaxValue = 1.0, MinValue = -1.0 }); return effects; }
// Use this for initialization void Start() { bright = GetComponent <BrightnessEffect>(); bloom = GetComponent <BloomOptimized>(); }
/// <summary> /// TODO: Apply filter to image /// </summary> /// <param name="fileStream"></param> private async void ApplyEffectAsync(IRandomAccessStream fileStream) { double scaleFactor = 1.0; scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; _writeableBitmap = new WriteableBitmap((int)(Window.Current.Bounds.Width * scaleFactor), (int)(Window.Current.Bounds.Height * scaleFactor)); _grayscaleEffect = new GrayscaleEffect(); _brightnessEffect = new BrightnessEffect(_grayscaleEffect); // m_renderer = new SwapChainPanelRenderer(_brightnessEffect, SwapChainPanelTarget); string errorMessage = null; try { // Rewind the stream to start. fileStream.Seek(0); // Set the imageSource on the effect and render. ((IImageConsumer)_grayscaleEffect).Source = new Lumia.Imaging.RandomAccessStreamImageSource(fileStream); await m_renderer.RenderAsync(); } catch (Exception exception) { errorMessage = exception.Message; } }