1

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

人们建议的另一种方法是实现 Direct2d,然后使用它进行应用。但为此,我需要编写 C++ 代码,而我的经验为零。

任何人都可以建议一些其他方法来在 c# 中实现 Instagram 效果吗?

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

4

1 回答 1

1

Please see this example from CodeProject : Metro Style Lightweight Image Processing

The above example contains these image effects.

  • Negative
  • Color filter
  • Emboss
  • SunLight
  • Black & White
  • Brightness
  • Oilpaint
  • Tint

Please note above example seems to be implemented on either developer preview or release preview of Windows 8. So you will get error like this

'Windows.UI.Xaml.Media.Imaging.WriteableBitmap' does not contain a constructor that takes 1 arguments

So you have to create instance of WriteableBitmap by passing pixel height and pixel width of image. I have edited the sample and it is working for me. You have to change wb = new WriteableBitmap(bs); to 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;
}

Let me know if you are facing any problem.

于 2013-03-26T07:37:44.767 回答