2

谁能告诉我在开发 Windows 8 应用程序时 System.Drawing 的替代品是什么。我尝试了 System.Drawing,但 Windows 8 应用程序不支持它。我必须使用 Image.FromFile() 但它在 Windows 8 中显示错误。它在控制台应用程序中工作正常。

4

2 回答 2

2

也许这篇来自 MSDN 的文章可能会对您有所帮助:基于 XAML 矢量的绘图示例

样本涵盖:

  • 使用 Rectangle 、 Line 、 Ellipse 和 Polygon 类绘制基本形状。
  • 应用 Stroke 和 Fill 值来定义形状的轮廓和内部的外观。
  • 应用 LinearGradientBrush 填充。通过设置 Clip 属性来剪辑元素。
  • 使用包含各种形状、图形和贝塞尔曲线的路径元素绘制复杂的复合形状。

编辑:

对于 Windows 8,没有 System.Drawing 命名空间,而是Windows.Graphics.Imaging 命名空间。如果您点击链接,您会发现一些示例/文章解释了如何处理图像文件、如何编码(来自图像的文件)或解码(来自文件的图像)或如何编辑图像

希望这可以帮助您进一步!:)

于 2013-06-26T11:20:22.383 回答
0

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);
于 2013-06-27T09:23:58.630 回答