Resizing an image with Win2D

resizing_with_win2dLast week I had the opportunity to attend Simon Tao’s talk at Build 2015 Introducing Win2D: DirectX-Powered Drawing in C# and was thankfully introduced to the power and simplicity of Win2D. It feels like a drawing surface as simple to use an HTML 5 canvas, but using DirectX and ready for Windows apps (8.1 and 10).

I’m intending to eventually try out some fun drawing experiments, but during the session the task that came to mind was opening a file on a device, resizing it and then saving the result as a new file. I was attempting to do this using WritableBitmaps, but the performance was sorely lacking.

I’ve successfully completed my first attempt at this task with Win2D and the results are great. Super fast resizing and simple C# code to understand. One option the experiment includes is to use logical dpi or actual dpi (do you want the image to be 300 wide in Length, or the image file saved at 300 pixels wide?)

Since I’m planning to do more experiments and code sharing I thought I would step into modern times and share via a github repository. You can find the ImageResize experiment for both Windows 8.1 and Windows 10 via WinGraphics.

Leave a Reply