Replacement of System.drawing in developing window

2019-02-27 02:45发布

Can any one tell me what is the replacement of System.Drawing in developing windows 8 apps. I tried System.Drawing but it is not supported by windows 8 apps. I have to use Image.FromFile() but it is showing error in windows 8. It is working fine in console application.

2条回答
唯我独甜
2楼-- · 2019-02-27 03:33

Perhaps this article from MSDN might help you out: XAML vector-based drawing sample.

The sample covers:

  • Drawing basic shapes using the Rectangle , Line , Ellipse , and Polygon classes.
  • Applying Stroke and Fill values to define the appearance of the outline and interior of the shape.
  • Applying a LinearGradientBrush fill. Clipping elements by setting the Clip property.
  • Drawing complex, compound shapes using Path elements that contain various shapes, figures, and Bezier curves.

Edit:

Instead of the System.Drawing namespace, for Windows 8 there is the Windows.Graphics.Imaging namespace. If you follow the link you'll find several samples/articles explaining how to process image files, how to encode (file from image) or decode (image from file) or how to edit an image.

Hope this helps you out further! :)

查看更多
迷人小祖宗
3楼-- · 2019-02-27 03:34

I used the namespace Windows.Graphics.Imaging and tried to convert my tiff image into jpeg but it is not working. pls check the following code and tell me what i am doing wrong in the code.

                        Image myImage = new Image();
                        var stream = await image.OpenAsync(Windows.Storage.FileAccessMode.Read);
                        var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                        await bitmapImage.SetSourceAsync(stream);
                        myImage.Source = bitmapImage;
                        var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
查看更多
登录 后发表回答