本文介绍了如何在Windows Phone 8中保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


i在wp8中制作了灰度滤镜效果,现在我想保存它,但我的代码是保存原始图像而不是图像更改为灰度

这是我的灰度代码

Hii made a grayscale filter effect in wp8 and now i want to save it but my code is save the original image not the image changed to grayscale
this is my grayscale code

private WriteableBitmap GrayScale(BitmapImage bp)
{
    WriteableBitmap wb = new WriteableBitmap(bp);
    int[] grayPixel = new int[wb.PixelWidth * wb.PixelHeight];
    for (int i = 0; i < wb.Pixels.Length; i++)
    {
        int pixel = wb.Pixels[i];
        int red = (pixel & 0x00FF0000) >> 16;
        int blue = (pixel & 0x0000FF00) >> 8;
        int green = (pixel & 0x000000FF);
        int average = (byte)((red + green + blue) / 3);
        unchecked
        {
            grayPixel[i] = (int)((pixel & 0xFF000000) | average << 16 | average << 8 | average);
        }
    }
    Buffer.BlockCopy(grayPixel, 0, wb.Pixels, 0, (grayPixel.Length * 4));
    return wb;
}





这是我的保存方法



and this is my save method

private void SaveImage(WriteableBitmap wb)
{
    wb = new WriteableBitmap(bp);
    var fileStream = new MemoryStream();
    fileStream.Position = 0;
    wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
    fileStream.Seek(0, SeekOrigin.Begin);
    var m = new MediaLibrary();
    m.SavePictureToCameraRoll("text.jpg", fileStream);
}



我该怎么做才能保存我的图像效果不是原始图像

With Respect


what should i do to it save my image after effect not original image
With Respect

推荐答案


这篇关于如何在Windows Phone 8中保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 15:12