I am doing winrt application,i have an image which is circle, i need to clip the arc dynamically from the circular image, with different angles, how can i do this?
Asked
Active
Viewed 389 times
0
-
Which is it - WPF, Silverlight or WinRT/XAML? These are similar but different platforms and the imaging stacks are different enough to give you a different answer for each platform. – Filip Skakun Nov 26 '12 at 16:33
-
@FilipSkakun: i need winrt solution – pashaplus Nov 26 '12 at 16:47
2 Answers
0
In WinRT/XAML - you would open the image as a WriteableBitmap and process the pixels manually. You could also do it with DirectX if you have more time and want to get the results quicker.
Useful formulas for a circle to start with:
r2 = x2 + y2
x = r * sin(α)
y = r * cos(α)

Filip Skakun
- 31,624
- 6
- 74
- 100
-
-
No, unfortunately [UIElement.Clip](http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.clip) is only for RectangleGeometry and OpacityMask is not supported in XAML. You could still do it with DX though. – Filip Skakun Nov 26 '12 at 18:05
-
i dont know anything about directX,can you suggest any quick start tutorial? – pashaplus Nov 26 '12 at 18:25
-
I would suggest looking into SharpDX - just install the Direct2D component from NuGet. I just wrote some code to render some text to a bitmap that you might find useful [here](http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/585d3ae5a3e3#WinRTXamlToolkit.Composition%2fWriteableBitmapRenderExtensions.cs) – Filip Skakun Nov 26 '12 at 18:35
0
For completeness sake - you could make an Path/ArcSegment with ImageBrush Fill - similar to the first part of this answer here.