win2d

Drawing image using Blur effects in UWP is not properly set size for the image

风格不统一 提交于 2021-01-29 08:20:51
问题 I want to blur the image using slider. For this, I have used Win2D Blur effects and draw the image in CanvasControl and added the canvas over the actual image. Download sample here Steps. 1. Added CanvasControl in button click. It will add a child to grid over the actual element 2. Change Slider to apply the blur 3. Issue: Image stretched and it's size too large and look like cropped. Not in the given size (500, 400) [XAML] <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="7*"/>

Rotate Image in Win2D

╄→гoц情女王★ 提交于 2020-06-17 09:42:08
问题 I'm trying to rotate image but couldn't get expected result. I've tried with WIn2D but couldn't make image as expected. My tried Code public async void Rotate(string originalImagepath, Rect originalImageRect, float degrees) { int height = (int)Math.Sqrt(originalImageRect.Width * originalImageRect.Width + originalImageRect.Height * originalImageRect.Height); CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget webCardImage = null; CanvasBitmap bitmap = null; var logicalDpi

Win2D library: CanvasImageBrush paints using the Canvas coordinates?

孤人 提交于 2020-01-07 02:39:09
问题 G'day Folks, I've started to explore the Win2D library for a Windows 10 UAP app. I am drawing an ellipse and filling it using a previously defined CanvasImageBrush. It appears the coordinates being used as fill are based on the screen coordinates where the ellipse is drawn. In other words, an ellipse in the top left corner looks fine, but elsewhere on the page, the ellipse is filled with black. I set the ExtendX and ExtendY properties "Wrap" to test my hypothesis, and the ellipse is drawn as

Pinch and Zoom UWP default position and size

家住魔仙堡 提交于 2020-01-06 08:07:23
问题 I drawn some arc and lines in a canvas using WIN2D.To implements pan and pinch in the canvas image I was used the code below... XAML </Canvas>--> <ScrollViewer x:Name="scrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="-0,0,0,0" Height="806" ZoomMode="Enabled" MinZoomFactor="0.5" MaxZoomFactor="8000" ViewChanged="scrollViewer_ViewChanged"> <Grid Margin="-10,0,0,0"> <canvas:CanvasControl x:Name="ManipulateMe" Draw="Preview_Draw" Margin="-11,1,0,0"

Pinch and Zoom UWP default position and size

喜你入骨 提交于 2020-01-06 08:07:10
问题 I drawn some arc and lines in a canvas using WIN2D.To implements pan and pinch in the canvas image I was used the code below... XAML </Canvas>--> <ScrollViewer x:Name="scrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="-0,0,0,0" Height="806" ZoomMode="Enabled" MinZoomFactor="0.5" MaxZoomFactor="8000" ViewChanged="scrollViewer_ViewChanged"> <Grid Margin="-10,0,0,0"> <canvas:CanvasControl x:Name="ManipulateMe" Draw="Preview_Draw" Margin="-11,1,0,0"

UWP Composition - Apply opacity mask to top 30px of a ListView

爷,独闯天下 提交于 2020-01-01 09:26:07
问题 How can I apply an effect to a ListView where the top 30px graduate from fully transparent to fully opaque? The idea is that as you scroll down, the top items gradually fade away. I am building a UWP application where the design calls for the top 30px of a ListView to start at opacity 0 and transition to opacity 1. Conceptually I am imagining an Opacity Mask that would be applied to the top part of a SpriteVisual but I cannot work out how to achieve this. I am attempting this using the the

How to calculate the size of a piece of text in Win2D

好久不见. 提交于 2020-01-01 08:59:08
问题 I am writing an application for Windows 10 using Win2D and I'm trying to draw a shape which scales dynamically to fit whatever text happens to be in it. What I'd like to do is work out how big a particular string would be with a given CanvasTextFormat and then use that to set the size of the shape. My problem is I can't seem to find a way of working out how big the string will be? 回答1: See code below to calculate the required size (look for "theRectYouAreLookingFor") private void

UWP: Compute text height in a RichTextBlock gives weird results

一个人想着一个人 提交于 2019-12-24 07:30:48
问题 I need a reliable method to get the height of the text contained in a RichTextBlock , even before it is actually drawn on the scene. Using the normal Measure() method produces a weird result, as it can be seen in the MVCE: https://github.com/cghersi/UWPExamples/tree/master/MeasureText (I want to keep fiexed the width, and measure the final height, but the result of DesiredSize is far different from the actual height!!). For this reason, I found a rough method (mentioned here https:/

Support more than one color input in my Pixel Shader (UWP, Win2D)

北慕城南 提交于 2019-12-24 05:33:07
问题 I've been working on an app that can provide Color Replacement, and had a lot of help from @Jet Chopper on a solution. He's provided me the following code which essentially uses a ControlSpectrum control for Source and Target colors. The idea is you specify a Source Color which then gets replaced by a Target color. Here's the current working code: This is my original post that contains the original solution with a GIF. Original Post XAML: <Grid> <xaml:CanvasAnimatedControl x:Name=

How to pull missile images on top of the lines?

守給你的承諾、 提交于 2019-12-11 06:35:16
问题 As you can see below, the images of the little missiles are not over the lines. How can I create an offset that respects the angle and rotation. I am using linear interpolation to extract x y coordinates between the ends of each straight line. float xDiff = end_xpos[i] - start_xpos[i]; float yDiff = end_ypos[i] - start_ypos[i]; double degrees = Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI; double radians = (Math.PI / 180) * degrees; args.DrawingSession.DrawLine(start_xpos[i], start_ypos[i], end