請參閱從CodeProject這個例子:Metro Style Lightweight Image Processing
上面的例子包含這些圖像效果。
- 負
- 彩色濾光片
- 浮雕
- 陽光
- 黑&白
- 亮度
- 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;
}
讓我知道如果你面對任何問題。