Instagram照片效果在Windows 8地铁应用程序使用c#

本文关键字:应用程序 地铁 Windows 照片 Instagram | 更新日期: 2023-09-27 18:02:55

我需要实现Instagram照片效果,如amaro, hudson, sepia, rise等。我知道这篇文章只使用基本效果:http://code.msdn.microsoft.com/windowsdesktop/Metro-Style-lightweight-24589f50

人们建议的另一种方法是实现Direct2d,然后使用它应用。但要做到这一点,我需要编写c++代码,而我在这方面毫无经验。

谁能建议一些其他的方法来实现Instagram的效果在c#?

是否有任何内置的c++文件来实现这些效果?

Instagram照片效果在Windows 8地铁应用程序使用c#

请看这个来自CodeProject的例子:Metro Style轻量级图像处理

上面的例子包含了这些图像效果。

  • -
  • <
  • 的彩色滤光片/gh>
  • 浮雕
  • 阳光
  • 黑色,白色的
  • <
  • 亮度/gh>
  • Oilpaint
  • 色彩

请注意上面的例子似乎是在Windows 8的开发者预览版或发布预览版上实现的。你会得到这样的错误

Windows.UI.Xaml.Media.Imaging。WriteableBitmap'不包含接受1个参数的构造函数

所以你必须通过传递图像的像素高度和像素宽度来创建WriteableBitmap的实例。我已经编辑了样本,它是为我工作。您必须将wb = new WriteableBitmap(bs);更改为wb = await GetWB();

StorageFile originalImageFile;
WriteableBitmap cropBmp;
public async Task<WriteableBitmap> GetWB()
{
    if (originalImageFile != null)
    {
        //originalImageFile is the image either loaded from file or captured image.
        using (IRandomAccessStream stream = await originalImageFile.OpenReadAsync())
        {
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(stream);
            BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
            byte[] pixels = await GetPixelData(decoder, Convert.ToUInt32(bmp.PixelWidth), Convert.ToUInt32(bmp.PixelHeight));
            cropBmp = new WriteableBitmap(bmp.PixelWidth, bmp.PixelHeight);
            Stream pixStream = cropBmp.PixelBuffer.AsStream();
            pixStream.Write(pixels, 0, (int)(bmp.PixelWidth * bmp.PixelHeight * 4));
        } 
    }
    return cropBmp;
}

如果你遇到任何问题,请告诉我。