Giter Club home page Giter Club logo

microsoft / win2d Goto Github PK

View Code? Open in Web Editor NEW
1.8K 189.0 284.0 49.46 MB

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.

Home Page: http://microsoft.github.io/Win2D

License: Other

C++ 91.52% C# 8.04% C 0.04% Batchfile 0.17% PowerShell 0.22%

win2d's Introduction

Transitioning Win2D to Reunion is In-Progress

Moving Win2D over to WindowsAppSdk and WinUI3 is a work in progress, and some features such as CanvasAnimatedControl have partial or no support.

Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for WinUI3. It utilizes the power of Direct2D, and integrates seamlessly with XAML.

Visit the DirectX Landing Page for more resources for DirectX developers.

Where to get it
How to use it
More info

Code Example

To give you a flavor of what the code looks like, here is a snippet of XAML:

xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"

<Grid>
    <canvas:CanvasControl Draw="canvasControl_Draw" ClearColor="CornflowerBlue" />
</Grid>

and C#:

void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow);
}

or C++/CX:

void MainPage::CanvasControl_Draw(CanvasControl^ sender, CanvasDrawEventArgs^ args)
{
    args->DrawingSession->DrawEllipse(155, 115, 80, 30, Colors::Black, 3);
    args->DrawingSession->DrawText("Hello, world!", 100, 100, Colors::Yellow);
}

or C++/WinRT:

void MainPage::CanvasControl_Draw(CanvasControl const& sender, CanvasDrawEventArgs const& args)
{
    args.DrawingSession().DrawEllipse(155, 115, 80, 30, Colors::Black(), 3);
    args.DrawingSession().DrawText(L"Hello, world!", 100, 100, Colors::Yellow());
}

or VB:

Sub canvasControl_Draw(sender As CanvasControl, args As CanvasDrawEventArgs)
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3)
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow)
End Sub

Using Win2D

The documentation explains how to install Visual Studio, add the Win2D NuGet package to your project, and get started using the API.

Building Win2D from source

Requirements
  • Visual Studio 2019 16.9 with Tools for Universal Windows Apps 15.0.27428.01 and Windows SDK 18362
Clone Repository
Build NuGet Packages
  • Launch 'Developer Command Prompt for VS2019'
  • Change directory to your cloned Win2D repository and run 'build'
Point Visual Studio at the resulting 'bin' directory
  • In Visual Studio, go to 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Settings'
  • Choose 'Package Sources'
  • Click the '+' button to add a new source
  • Set 'Name' to 'Win2D' (or a name of your choosing)
  • Set 'Source' to the full path to the 'bin' directory (inside your cloned Win2D repository)
  • Click the 'Update' button
  • Click 'OK'

Locally built versions of Win2D are marked as prerelease, so you must change the 'Stable Only' setting to 'Include Prerelease' when adding them to your project.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

win2d's People

Contributors

13thsymphony avatar austinkinross avatar azchohfi avatar berrysoft avatar bricelam avatar clandrew avatar coopp avatar damyanp avatar danmclachlan avatar davidni avatar gegao18 avatar getrou avatar goh-chunlin avatar harneetsidhana avatar iablaauw-ms avatar kmgallahan avatar lindexi avatar microsoft-github-policy-service[bot] avatar milesmscohen avatar mjeanrichard avatar nlisotools avatar nukepayload2 avatar sergio0694 avatar shawnhar avatar thraka avatar wjk avatar zerhacken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

win2d's Issues

Support for spritesheets

What are your plans concerning spritesheets? I could not see anything in the backlog related to it.

TrackAsyncAction for Draw

Are there plans to have a TrackAsyncAction() method on CanvasDrawEventArgs like there is on CanvasCreateResourcesEventArgs?

Add Support for CharacterSpacing

Currently, Win2D does a great job of supporting most of the DirectWrite features, covering most of the IDWriteTextFormat object with CanvasTextFormat.

Currently however, one rather important typographical feature it is missing is support for adjusting character spacing, which of course isn't in the IDWriteTextFormat interface, nor infact the IDWriteTextLayout interface but the IDWriteTextLayout1 interface. Yay ;____;

I can see TextLayout is on the roadmap - any chance it will implement the IDWriteTextLayout1 natively as well to support CharacterSpacing?

(I'm currently hacking together myself an implementation in the interim, emphasis on hacky as I have very little C++ experience)

Custom Font Loading not working properly

In essence, it seems very prone to entirely locking up the application (running using the latest nuget package)

This does not work (creating the font family drawing the draw call)

private void cControl_Draw(Microsoft.Graphics.Canvas.CanvasControl sender, Microsoft.Graphics.Canvas.CanvasDrawEventArgs args)
        {
            using (var _localformat = new CanvasTextFormat()
            {
                FontFamily = "Symbols.ttf#Symbols",
                FontSize = 30
            })
            {
                args.DrawingSession.DrawText("Hello world", new Vector2(10, 10), Colors.Magenta, _localformat);
            }

            sender.Invalidate();
        }

Whilst declaring statically does:

static CanvasTextFormat _format
            = new CanvasTextFormat()
            {
                FontFamily = "Symbols.ttf#Symbols",
                FontSize = 30
            };

        private void cControl_Draw(Microsoft.Graphics.Canvas.CanvasControl sender, Microsoft.Graphics.Canvas.CanvasDrawEventArgs args)
        {
            args.DrawingSession.DrawText("Hello world", new Vector2(10, 10), Colors.Magenta, _format);
            sender.Invalidate();
        }

Now, I'm not actually doing this every draw call in my real app, but I am changing the Font Families regularly and it does seem to just lock the application with no errors thrown. I hope I'm not going crazy and doing something wrong! :P

Usage within user controls and per instance memory usage

We are looking to utilise Win2D in a few of our user controls on Windows Phone, but we've noticed that the per instance memory usage can be quite high, approx 1.5MB according to the profiler.

Given that one of the controls we are looking at using Win2D for is related to textual effects and there could quite easily be quite a few instances are they any ways which we can reduce the memory footprint?

It should be noted that these controls don't utilise any animations but rather utilise the GPU for speedier rendering of effects.

VS2013 not responding on opening of solution

This is probably due to my limited experience with this type of solution, but I can't get past the "Initializing Projects... (0 of 38) - winrt.text.external.Windows" stage of opening the solution. I've tried downloading a zip of the solution and cloning the repository. I've waited hours for it to finish loading and it won't finish. I've reset setting and disabled a few extensions so that it doesn't lock up VS anymore, but it will never finish the "Initializing Projects" status.

Does anyone have a quick solution to this? Thanks.

CanvasControl with zero size throws exception

If I put a simple CanvasControl in the XAML like this, it blows up with a "The parameter is incorrect." exception at runtime:

<Border Margin="20" BorderThickness="1" BorderBrush="Red" HorizontalAlignment="Left" VerticalAlignment="Top">
    <canvas:CanvasControl x:Name="canvas2D" />
</Border>

If I set a Width/Height on the control, it will load up without problems.

Support building for AnyCPU

It has been a real pain to have to switch to CPU-specific builds in order to take a dependency on Win2D. Not only are the builds longer and the package size bloated, but I'm losing tooling support in Visual Studio.

I no longer have a design view of my XAML files, which is a productivity killer!

[I'm pretty sure that SharpDX supports AnyCPU somehow, so maybe take a page from their book?]

Support for Shaders

Shaders support will be awesome. So developers will be able to write and use their own effects instead of using pre-built ones.

[N/A]

Nosing through the classes, it seems that RenderTarget and CanvasDrawingSession duplicate a lot of the same methods (and even have different enums for what seem like the same things, but named differently), but they're not related / inherited / implementing the same interfaces as each other

I'm not sure if this is already covered under this point (•Debt: CanvasDrawingSession architecture is focused on CanvasImageSource and doesn't fit nicely with anything else), but is there any plan going forward to make the two closer related too each other at this level?

Point in case, I wanted to pass either a CanvasDrawingSession or a RenderTarget too a method depending on what drawing context I was in, something that shouldn't matter either/or as they both implement drawing primitives that are nearly identical seeming, but I can't easily do that with the current structure

mouse/pointer/touch related events

Let's assume I drew several bitmaps on the canvas using the DrawImage method. How can I react to pointer events for each bitmap (e.g. to move the bitmaps around)?

Possible to render to a brush?

It would be interesting to set up an animation, and be able to use it as a control background. Is this possible? Could it be possible in the future?

Recieve Input events on AnimatedCanvasControl whilst paused?

Hey there,

So I'm looking at switching from CanvasControl to CanvasAnimatedControl - but in my application I only need to redraw the screen when the user is interacting with the canvas (which will be ~50% of the time), and I want the interactions to be as responsive as possible.

From what I've seen the input events seem to get processed faster when using CanvasAnimatedControl - however for the sake of battery life and processor usage I don't want / need it's render thread running all the time. So, I could pause it when the user removes their finger, and then resume the render thread when they start directly interacting with the canvas again.

Sounds logical to me, but at the moment pausing the CanvasAnimatedControl also seems to pause processing input events. I could potentially use the XAML PointerDown/Pressed event to start up the render thread but that doesn't work won't see the pointer down event. Is there some specific technical reason why it's not a good idea to let us choose to always process the events.

EDIT: And of course, just after I've posted this I've seen this on the backlog. Well, +1 for this being done then! :P I'll close this for not reading properly

CanvasDrawingSession.DrawLineString?

I might be missing it, but is there a way to draw a line consisting of more than two points? (Other than calling DrawLine for each segment).

It looks like it has been thought of as CanvasStrokeStyle has a LineJoin property, but the DrawLine implementations all only take two points.

Windows 10?

is there any commitment from Microsoft that Win2D will be compatible with Windows 10? I dont particularly see any reason why it wouldnt be, but there is a lot of unknowns when it comes to 10 right now.

Guidance on accepting input over a large CanvasControl

Hello, I know that for your current sprint you are working on some code related to swap chains. I'm admittedly a newbie to DirectX so your Win2D wrapper has been great thus far in making it easier for us higher level people to use it. I was hoping to get some guidance on how to handle scenarios of accepting input in a performant way over a large CanvasControl.

At the moment, I'm rendering several large screen-filling graphics in a CanvasControl in its Draw method. I have the CanvasControl in a WinRT template control of my own that overrides its OnPointerPressed, OnPointerMoved, etc. methods. Basically as the user holds the left mouse button down, i'm trying to update the backing bitmaps and then repaint the CanvasControl. While this works if I move the mouse very slowly, when I zip it around, I see that most of the pointer move events seem to get skipped. If I skip invalidating the CanvasControl in my OnPointerMoved method and only do it in OnPointerReleased, then all my input seems to be gathered but I have no real-time feedback to the end user.

I suspect that what I'm trying to do might not yet be supported in Win2D, but could you tell me if it is and if not, is something coming that will allow me to continue to get full-fidelity performant input so that I can update my backing bitmaps, while asynchronously repainting too? Any feedback you have on this subject or plans for the future would be helpful.

WinRT information: Cannot create instance of type 'Microsoft.Graphics.Canvas.CanvasControl'

I've tried to follow the instructions from http://microsoft.github.io/Win2D/html/Introduction.htm, but I'm getting the following error:

An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in Win2d.Windows.exe but was not handled in user code

WinRT information: Cannot create instance of type 'Microsoft.Graphics.Canvas.CanvasControl' [Line: 12 Position: 31]

Additional information: The text associated with this error code could not be found.

Please add support for loading and displaying SVG images

Please add support for loading and displaying SVG images. The majority of 2D graphic assets (sprites, background, ui, animations, etc.) of games are made with Inkscape and Illustrator in SVG. Porting those games from the other platforms (web, mobile, etc.) using Win2D would be a breeze with SVG support.

CanvasDrawingSession.DrawRectangle bug

I noticed what I think is a bug in DrawRectangle. It can be reproed with this test:

e.DrawingSession.Clear(Color.FromArgb(255, 0, 0, 0));
e.DrawingSession.FillRectangle(2, 2, 4, 4, Color.FromArgb(255, 255, 0, 0));
e.DrawingSession.DrawRectangle(1, 1, 6, 6, Color.FromArgb(255, 0, 255, 0));

What I would expect to see is a red filled rectangle starting 2 pixels in from the left/top and 4 pixels wide/high. Then the green border (via DrawRectangle) directly surrounding the red fill by starting at 1,1 and being 6 pixels wide/high.

What we get from DrawRectangle instead is a border that starts at 0,0 and goes 7 pixels wide/high, which is wrong.

No interop access to ID2D1DeviceContext

I have tried getting ID2D1DeviceContext from CanvasDevice and failed - probably only possible to get ID2D1Device? If so, any way to get the device context - I need it to create a custom image..

Can Install Win2D NuGet Package!

I cant find a way to Install Win2D Nuget after building the repository solution! Please help me immediately! I'm using Visual Studio Professional with Update 2! I followed instructions but when I open 'NuGet Package Manager' -> 'Manage NuGet Packages for Solution' and click Win2D (as I named in the Source Package), it says no items.

CanvasControl in ContentPresenter in ViewModel bound to ContentControl in View throws exception

There may be a better way to do what I want to do, but I'm trying to setup an MVVM pattern where I do all the CanvasControl drawing in a ViewModel. I'm just leaving all the basic XAML controls to the View.

In any case, I use a ContentControl on the View and bind a ContentPresenter from the ViewModel that has the CanvasControl as its content. This throws an ArgumentException every time.

I'm reverting to placing the CanvasControl directly into the XAML and trying to use Behaviors to handle the Draw event. I'm a bit stuck on how to call Invalidate() in my timer loop from the ViewModel when the control is in the View, but I suppose I will figure it out at some point.

Cannot create screen-size CanvasRenderTarget for Windows Phone

I have just met a problem: I am trying to create a Screen-sized CanvasRenderTarget on my Windows Phone (Lumia 1520, WP 8.1). I am getting 'Invalid arguments' exception, and my code is:

m_renderTarget = ref new CanvasRenderTarget(canvasControl, (float)m_nWidth, (float)m_nHeight,
  DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized, CanvasAlphaMode::Premultiplied);

where m_nWidth == 1080 and m_nHeight == 1864.

The most weird for me is that CanvasBitmap of the same size just got created one line above without any issues.
Same code on Windows works fine too - CanvasRenderTarget gets created without issues.

CanvasControl memory leak?

I've been trying to track down a memory leak in my application, and I seem to have tracked it down to something to do with the CanvasControl

I've reproduced the issue somewhat in a very basic example application here. If you enabled Profile in VS and switch backwards and forwards between the two pages, you'll see application usage grow (albeit slightly) each time. This get exacerbated in my actual application when I'm rendering actual content in the CanvasControl and on the surrounding page.

(I can't really see anything helpful in the memory profiler either, other than "Overlapped Data" - I have no diea what that is. You can also observe a memory leak in the sample app - navigate forward and backwards between the hubpage and the shape / stroke styles pages and watch the memory grow, although I've not looked at whether there are any obvious causes for that particular leak)

Very simple sample project here:

https://onedrive.live.com/redir?resid=DE47921B27CEAD6E!149144&authkey=!AKVhsU_ebScBXuw&ithint=file%2czip

Is this reproducible on your end?
Thanks!

Arithmetic result exceeded 32 bits with large image.

I am trying to open a .png file with dimensions of 40,000x40,000 pixels in a 64-bit application using the WARP device, but I am getting the error

HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) : Arithmetic result exceeded 32 bits. 

This is thrown from CanvasDevice.cpp:476. Is this a limitation in Direct2D or in Win2D?

Pattern for animation usage

Hi,

I know its early days and tutorials usually come a bit later but could you post a brief usage pattern for animating using Win2D?

It seems that you put draw code in an event handler on the canvas Draw event, however on running the code this only seems to get called once.

Do we need to manually call some kind of Draw method on the canvas object? If so how should we do this in order to animate in a non-blocking way? Using the Timer object puts it into another (non-UI) thread and generally doing this means we have to Dispatch.BeginInvoke back to the UI thread.

What is the expected way to animate using Win2D?

CanvasControl doesn't redraw anymore after app has been suspended

I'm using Win2D for an app since it's the most lightweight solution for having Direct2D without messing with native code, and I have to say that it's quite nice! However, I have found a bug that can be reproduced following these steps:

  • Create a new Universal App project.
  • Add Win2D to the Windows Phone project.
  • Add a CanvasControl to the main page.
  • Subscribe to the Draw event from XAML.
  • Do whatever you want inside the Draw callback, just clearing to a colour works.
  • Deploy the app to a device, and launch it from there. Just don't execute from the debugger.
  • Run the app and switch to another one. Open some new apps or lock the device so the app suspends, this works faster in low end devices.
  • Return to the app. The CanvasControl doesn't display anymore.

Should I be forcing a control invalidation so it redraws or is it expected to work automatically?

Guidance on Very Large Bitmaps

I am writing an application that will have to handle very large bitmaps (the current largest is 16128x14960 pixels but we expect bigger).

Do you have any guidance on this? I am assuming that the correct way to go about handling such large images would be to use a downscaled image for viewing the whole thing and moving to tiles when the user zooms in?

What would the best way be to go about loading such tiles?

In addition, the bitmaps will need to be editable. Will this even be possible? The current version of this application uses GDI and although it struggles, it can just about manage. I'm hoping it will be possible with Win2D...

DrawImage with Effects does not allow Rect argument

With the 0.8 version, if the first arg of DrawImage is an CanvasBitmap, you can use a second argument of Rect to draw the image into the Rect (with scaling). However, it seems that a second argument of Rect is not allowed if the first argument is instead an Effect.

args.DrawingSession.DrawImage(effectGraph,rect)

Is this by design, or an omission that may be fixed later. As a workaround, I am using an extra ScaleEffect and then using DrawImage with a second argument of Vector2 which places the effect where I wanted the Rect originally (which works).

Guidance for rendering with different transforms (separate DrawingSessions) for each frame

As far as I understand the only way to get a DrawingSession is to capture it from the arguments sent to the CanvasControl.Draw event. But this means that each rendered frame needs to be batched with the same properties for transformations (scale possibly) and states. Is there some way to create additional DrawingSession instances that can be leveraged for multiple batches for each frame?

Or am I missing the point?

Allow the DrawImage overrides that need an ICanvasImage to specify destination rectangle

I'm using the Win2D control for adding rich image effects to a Windows Phone application. Right now I'm using a GaussianBlurEffect to animate the transition between two images, but I have found that the DrawImage overrides that let me use the output of an effect (those that accept an ICanvasImage instead of a CanvasBitmap) don't have any way of specifying a destination rectangle.

Is this feature going to be considered or should I use another approach (intermediate render target, draw to bitmap, etc.)?

Missing the dots in stroke dash styles with dots

Just ran the example gallery and noticed that the dots are missing in the stroke dash styles containing dots. This means that the app does not show anything when Dot is selected as dash style.

Known issue or more info needed?

Add support for WPF

Please consider adding a set of import/exports and C# wrapper around the imports to get the same API in WPF but rendering to a D3DImage instead. WPF is big. Don't forget about it. It would also serve as a great best-practices example how to compose DirectX content into WPF.

Allow brush mapping mode?

WPF Linear/Radial brush has mapping mode which can be Absolute or RelativeToBoundingBox, in this way user can specify values in range 0..1 and apply the custom brush transform calculated related to the shape rendering bounds (IE: Rect bounds, Ellipse, Shape bounds).

Push forward CustomFontLoading #backlog suggestion

I'd like to put forward a vote for pushing custom font loading forward. Win2D can already do a lot with text, and I can apply a lot of effects and transforms too it all - but it all comes a bit undone when I'm stuck with only using system fonts (which are quite limited on the phone)

Combined with SharpDX I can get the FontMetrics and what not without waiting for Win2D to implement it, but it would be very nice to have custom font loading pushed forward. (No idea if that relies upon implementing a CanvasTextLayout or similar requiring you to basically bring forward all of text updates)

Error in Visual Studio 2015 CTP6

The Nuget Win2D package install successfully, but compile fails (even an empty project) with the error:

'Could not find SDK "Microsoft.VCLibs, Versio=12.0"'

CanvasImageBrush seems to lock GaussianBlurEffect

When I write the following code:

        args.DrawingSession.DrawImage(_canvasBitmap, 0, 0);

        var blurEffect = new GaussianBlurEffect
        {
            Source = _canvasBitmap,
            StandardDeviation = 3f
        };

        var brush = new CanvasImageBrush(sender, blurEffect)
        {
            SourceRectangle = _canvasBitmap.Bounds,
            Transform = Matrix3x2.CreateScale(0.5f),
            ExtendX = CanvasEdgeBehavior.Mirror,
            ExtendY = CanvasEdgeBehavior.Wrap
        };
        // draw second image with CanvasImageBrush
        args.DrawingSession.DrawImage(blurEffect, 0, 338);

I've got an UnhandledException.
Strange thing is that brush is not used. If I comment the "var brush..." line, not exception.

Issue with Layers on Windows Phone?

I was wondering is there are any know issues with D2D layers in general on Windows Phone? (other than it being not-too-performance friendly)

I've attached a video of my issue ( as I'm having trouble getting a slim repo project at the moment), but basically sometimes if I use layers, my rendering breaks, and it also causes glitches to the rendering of the XAML parts of my UI as well. (In the video, the bar at the bottom is not a Windows Phone app bar, but just a normal Stackpanel / grid combo. You'll see it's rendering flashing all over the screen. If I take the layer call out, everything works perfectly all of the time :/

This is using a CanvasAnimatedControl inside a XAML page on Windows Phone 8.1 Update (Lumia 1520 with Black update). Also happens on a Lumia 635

Now, this black background / repeated texture also only happens if the last layer I created was the one that for some reason failed (although in the case of this app, the rendering code for each layer is exactly the same, as I'm rendering the same thing in different positions, using layers for optional opacity). If I create another layer call after this (which you see in the video when I add another copy), the screen renders fine again apart from the fact that broken layer simply doesn't render at all.

It looks like it might be a problem with the driver or a bug in D2D in general? (It's worth pointing out I've seen similar things happen not-too-infrequently in Internet Explorer on lower powered devices, although never on the one I recorded the video on - Lumia 1520)

Video: https://onedrive.live.com/redir?resid=DE47921B27CEAD6E!185016&authkey=!AELNCgKcIo-nFN4&ithint=video%2cmp4

Fail to compile 0.0.13

d:\win2d-master\winrt\lib\canvasbrush.h(51): error C2220: warning treated as er
ror - no 'object' file generated [D:\Win2D-master\winrt\lib\winrt.lib.WindowsPh
one.vcxproj]

Gradient brushes are created with CanvasEdgeBehavior::Wrap by default

The CsConsumer Gradients demo uses a radial gradient brush and a linear gradient brush, both of which are created with CanvasEdgeBehavior::Wrap. This causes the edge of the drawn shapes to show an undesirable border (in the case of the circle, a bad-looking dark border; in the case of the rectangle, a thin red line in the purple end).

IMHO using CanvasEdgeBehavior::Clamp by default would make more sense, and I already have a fix that does that in my fork. I'll send a PR shortly.

Here's a screenshot of the circle looking particularly bad:

image

Using Win2D in a library? (PCL?)

I'm a total beginner when it comes to writing Windows Runtime apps, so please forgive me if my question is stupid! To me Win2D looks great and without it, I wouldn't even consider WinRT as a platform for an app I currently want to make. (I think it is essential for MS to make their platform attractive to .NET-developers in order to keep Windows alive and well, and I think Win2D is very important in this regard.)
But as F# is my preferred language for app development, it's rather hard to get started.
It seems currently impossible to NuGet install-package Win2D into a library project, irrespective of whether it is C# or F#. Is it possible to install Win2D, preferrable via NuGet, into library projects now, or is it planned in the future?

Creating a F# PCL (not referencing Win2D) and calling that from within a universal app works well, but I really want to have as much code as possible in F#, so I'd like to call the Win2D API directly from within my F# code and I haven't been able to do that. Has anyone had any luck calling Win2D from F# or from a C# library project?

Using Win2D 0.0.0.14 causes app to fail Cert test on Windows Phone store?

Alright, so this is an odd one.

Building with the latest Win2D package with VS 2013 Update 4 (or also VS 2015 CTP 5) is good - the package builds. Run Windows App Cert Kit (3.4) locally, the application passes validation - as you would expect.

Now, submit the app to the Windows Phone Store (in my case, the Windows Phone Store as an update to an app using 0.0.0.13) - and it gets to running through the same Windows Cert Kit version on the store - only for it to consistently fail:

FAILED
Supported APIs
Error Found: The supported APIs test detected the following errors:
This API is not supported for this application type - Api=12. Module=d2d1.dll. File=Microsoft.Graphics.Canvas.dll.
Impact if not fixed: Using an API that is not part of the Windows SDK for Windows Phone Store apps violates the Windows Phone Store certification requirements.

Googling, it seems someone else has the same problem with D2D api's & the Store Cert Kit online https://social.msdn.microsoft.com/Forums/vstudio/en-US/4d93e0c4-aa30-4754-b275-3e4f322ff624/supported-api-test-fail-d2d1?forum=wingameswithdirectx - in his case the use of D2D1::ComputeFlatteningTolerance. (which in Win2D's case may have been used for Geometry support?). It seems like for some reason, even though whatever API is actually causing the issue does seem to actually be supported by Windows Phone and run fine, the store is having none of it.

Now, I don't know where the right place to post this - as it might just be a problem with the store - but I feel it's worth posting here as it seems to make Windows Phone apps un-submitable at the moment.

(Alternatively, something has gone horribly wrong with my set up - also likely possible)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.